Operating System - HP-UX
1819791 Members
3264 Online
109607 Solutions
New Discussion юеВ

To schedule a job every 2.30 hours interval through crontab...

 
Deepu Chakravarty
Regular Advisor

To schedule a job every 2.30 hours interval through crontab...

Is there any possibility to schedule a job through crontab which runs every two and half hours interval? Other parameters no problem.
If yes, How?
10 REPLIES 10
Peter Godron
Honored Contributor

Re: To schedule a job every 2.30 hours interval through crontab...

Deepu,
this is easier done with the at command.
man at
Devender Khatana
Honored Contributor

Re: To schedule a job every 2.30 hours interval through crontab...

Hi,

It is not possible. For this to achive you can schedule more than jobs. Scheduling two shall be enough.

at will not work as this will execute the job only once.

HTH,
Devender
Impossible itself mentions "I m possible"
Senthil Kumar .A_1
Honored Contributor

Re: To schedule a job every 2.30 hours interval through crontab...

Hi Deepu,

You cannot acheive a cyclic run with a time interval of 2 1/2 hours with cron. That would be possible with enterprise Job scheduler like BMC's Control M product etc...

If you want to run a script/command every 2 1/2 hours.. just write a script to run the program with sleep command.say u want to run /usr/bin/ls every 2 1/2 hours.. then my ksh script will look like..

#!/usr/bin/ksh
while true
do
/usr/bin/ls
sleep 9000
done

When u run this script, it will run "ls" command indefinitely with a interval gap of 2 1/2 hours.

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Deepu Chakravarty
Regular Advisor

Re: To schedule a job every 2.30 hours interval through crontab...

Hi Senthil,
But I want run it through a schedule job. So that manual intervention is not required.
Pete Randall
Outstanding Contributor

Re: To schedule a job every 2.30 hours interval through crontab...

Make a script and enter it into at

at now +150 minutes /full_path/myscript

Make the last line in your script read like this:

echo "/full_path/myscript" | at now + 150 minutes


Pete

Pete
Devender Khatana
Honored Contributor

Re: To schedule a job every 2.30 hours interval through crontab...

Hi,

As indicated earlier schedule two jobs for doing the same function at an interval of every 5 hours for both of them and at a difference of 2 & half hours among both of them.

crontab entry for such job should look like

For first job
00 1,6,11,16,21 * * *

For Second job
30 3,8,13,18,23 * * * /command


This will achive your task but with one interval being of 1&half hours instead of 2& half. This can be avoided by making a few more jobs and reducing the frequency in these two.

Other option as mentioned earlier can be used by running the code in the background and using sleep function.

HTH,
Devender
Impossible itself mentions "I m possible"
Deepu Chakravarty
Regular Advisor

Re: To schedule a job every 2.30 hours interval through crontab...

Pete,
whether 'at'(your suggestion) will run every 2.3 hours interval automatically? Or I have to submit the job manually at every specified interval ?
Peter Godron
Honored Contributor

Re: To schedule a job every 2.30 hours interval through crontab...

Deepu,
the at command will run 2.5 hours from the end of the previous job. No manual intervention is required, unless the job is killed. To start the job automatically at runtime, include in the /etc/rc3.d level.
Chris Watson
Super Advisor

Re: To schedule a job every 2.30 hours interval through crontab...

The best way to do this is to schedule the job to run on the thirtieth minute past the hour and every zeroth minute using cron.

Then in the script create a check that the invocation is one that you wish to progress with. You can implement this using control files or other means.
Moving along nicely
Pete Randall
Outstanding Contributor

Re: To schedule a job every 2.30 hours interval through crontab...

The last line of your script (myscript) will resubmit the job to at, to run in 150 minutes, or two and a half hours:

echo "/full_path/myscript" | at now + 150 minutes


Pete

Pete