Operating System - HP-UX
1753835 Members
7750 Online
108806 Solutions
New Discussion юеВ

Re: restarting script running as a cron job

 
SOLVED
Go to solution
Shivkumar
Super Advisor

restarting script running as a cron job

i have a shell sript running as a cron job. how to make sure it restart script when get stopped due to reboot or some other reason ?

Regards,
Shiv
10 REPLIES 10
Adisuria Wangsadinata_1
Honored Contributor

Re: restarting script running as a cron job

Hi Shiv,

Use this commands below :

To stop cronjob :
# /sbin/init.d/cron stop

To start cronjob :
# /sbin/init.d/cron start

Hope this information can help you.

Cheers,
AW
now working, next not working ... that's unix
Yogeeraj_1
Honored Contributor

Re: restarting script running as a cron job

hi,

In Oracle, the DBMS_JOB/DBMS_SCHEDULER package automatically re-runs the jobs that have been missed, but cron cannot.

Unfortunately, cron does not automatically re-run jobs that have not been executed due to reboot or some other reasons!

You will have to reschedule the execution (using cron itself then disable it) or run the script manually.

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Indira Aramandla
Honored Contributor
Solution

Re: restarting script running as a cron job

Hi Shivkumar,


You have a script that has been scheduled through cron. what frequency is the job scheduled to run for. is is every day at a certain time. In that case then if today it did not run then it will be run next day.

But if you want the script to run every day
and you want to make sure the job has run, then check for the output file or text in the directory when the job is run. If there is no output, then check for the job log. If this log or the output file is not generated then call the script again. By this you will make sure that the job is run.


IA

IA.
Never give up, Keep Trying
Hemmetter
Esteemed Contributor

Re: restarting script running as a cron job

Hi Shivkumar,

if your job is run via cron it will be restartet every configured time, whatever reason let it stop.

Do you need your script running permanently and to be restarted immediatly after termination? Then have a look at init(1) and inittab(4) manpages.

rgds
HGH
Tvs
Regular Advisor

Re: restarting script running as a cron job

hi.

in the crontab just redirect the output to one file.

( or just redirect the exit code to some files )

after that by verfiying the file u can find out the script stoped or completed successfully


regards

tvs
Cem Tugrul
Esteemed Contributor

Re: restarting script running as a cron job

Cem Tugrul
Esteemed Contributor

Re: restarting script running as a cron job

http://docs.hp.com/en/A2615-90003/ch16s04.html#d0e29852
Our greatest duty in this life is to help others. And please, if you can't
Howard Marshall
Regular Advisor

Re: restarting script running as a cron job

If you have a script that runs all the time you may want to put it in the rc startup instead of cron but if cron it must be and you want to restart it to keep it running after a reboot or after it dies you can use the at command

#>at now script

#>man at #for more detail

H
Raj D.
Honored Contributor

Re: restarting script running as a cron job

Hi Shiv ,

Redirect the stderr to a file and you are done.

You can know how the crontab job is performing , later by seeing the errlog.

It should be look like this:

#Run LogLooker security reports daily
32 15 * * * /usr/local/bin/loglooker/sad.sh -a -m root > /myhome/err.log 2>&1


hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "