mardi 19 janvier 2016

Ubuntu check if a job is running after a particular inerval of time, and if not then restart it

I am using resque to run few jobs. In that i have a job in am trying to run it in infinite loop by adding the code to enque the job in the task code itself. This works. But sometimes due to any issue, it fails an then to restart it again I have written a shell script to restart the job. This also works.

The problem i am facing is, when the shell script detects the stopped job and restarts it, then sometimes, instead of one worker, the job gets queued in 2 workers. I want to avoid this.

process=Process_name

ps auxw | grep $process | grep -v grep > /dev/null

    if [ $? != 0 ]
    then
            /bin/bash -l -c 'cd /path/to/directory && RAILS_ENV=production bundle exec rake monitor:start_job'
    else

    fi

Aucun commentaire:

Enregistrer un commentaire