1847314 Members
2457 Online
110264 Solutions
New Discussion

cronjob

 
atul.kaggarwal
Contributor

cronjob

How can i specify ifi want to run some process every 25 min
10 REPLIES 10
Oviwan
Honored Contributor

Re: cronjob

Hy

25 * * * * /path/to/jop

Regards
atul.kaggarwal
Contributor

Re: cronjob

Thanks for reply.. Please now let me know how can we specify a job if i want to run it EVERY 1:30 Hours i.e. 90 min
Dennis Handly
Acclaimed Contributor

Re: cronjob

You can't with crontab, only multiples or divisors of 60 minutes. Instead use at(1) and reschedule for 25 minutes later: at ... +25 minutes

Better yet, just use 30. For 30 you would use:
0,30 * * * * /path/to/jop

If you really really wanted to use 25, you would have to list all 57 values of 25 minutes in a 24 hour day.
Yogeeraj_1
Honored Contributor

Re: cronjob

hi

every 90mins would be: (suppose it started midnight: 1:30, 3:00, 4:30, 6:00, 7:30, 9:00, 10:30, 12:00, 13:30, 15:00, 16:30, 18:00, 19:30, 21:00, 22:30, 00:00)

#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
30 1,4,7,10,13,16,19,22 * * * /path/to/job
00 3,6,9,12,15,18,21,00 * * * /path/to/job

#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Dennis Handly
Acclaimed Contributor

Re: cronjob

If you want it to run every 90 minutes, you would have to list all 16 90 minute periods in a day. This is a simple two line crontab:
00 00,03,06,09,12,15,18,21 * * * command
30 01,04,07,10,13,16,19,22 * * * command
Yogeeraj_1
Honored Contributor

Re: cronjob

hi again,

if you want to "at" then it will be more simple since the time can be set relative to the last execution of the script.

e.g.

at -f /path/to/job +1.5 hours > /dec/null

(of course, you will need to set the appropriate permissions and include the command in the script itself)

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Dennis Handly
Acclaimed Contributor

Re: cronjob

>Yogeeraj: at -f /path/to/job +1.5 hours

You can't use 1.5 so you need: +90 minutes
Oviwan
Honored Contributor

Re: cronjob

You can also start a job once and include the following code:

i.e. for KSH:

while true
do

job....

sleep 5400

done
Dennis Handly
Acclaimed Contributor

Re: cronjob

Oops, that's: at now +90 minutes
Dennis Handly
Acclaimed Contributor

Re: cronjob

>Oviwan: start a job once...

This code does its work then waits 90 minutes. Depending on how long it takes, it won't be every 90 but may be close enough. If you want it accurate, you can get the start time and add 90 minutes and then sleep the difference when you recompute the current time when you are at the end of the loop.

>sleep 5400

This may be confusing. Either add comments or use:
sleep $(( 90 * 60 ))