Question: 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.

Answer: 
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??
I use [runit/sv](http://smarden.org/runit/) to manage delayed\_job. Includes monitoring, auto restarts, logging.