views:

136

answers:

3

I want to create a cront tab to restart my delayed_job server if it breaks.

how may check that my delayed_job server is running or not with ps command?

how may i create a cron tab to check this thing work? Like if my server break than cron tab will restart it. I want to set cront tab to check it every 5 minute.

+1  A: 

This is my script which check if pid files is created or not. If pid file is not exist than it will start the delayed_job server. I have created my script in my application root folder This is my script delayed_job.sh

if ! [ -s delayed_job.pids ]; then
  RAILS_ENV=production /app/script/delayed_job start
end

And i have set this script on crontab like this.

*/5 * * * * RAILS_ENV=production /bin/bash /app/delayed_job.sh

It's working fine. If i break delayed_job server than it will automatically start my delayed_job server. Is it a proper way??

krunal shah
A: 

I use runit/sv to manage delayed_job. Includes monitoring, auto restarts, logging.

Larry K
A: 

If you don't stick to cron, Monit may be more useful. http://mmonit.com/monit/

kdoya