Results 1 to 4 of 4
Hi All,
I have a question regarding running crontab.
In one of my Linux box, I need to run a job for every 7 hours. I have tried the below ...
- 03-19-2008 #1Just Joined!
- Join Date
- Aug 2007
- Posts
- 8
Running crontab for every 7 hours
Hi All,
I have a question regarding running crontab.
In one of my Linux box, I need to run a job for every 7 hours. I have tried the below method:
* */7 * * * script.sh
But here, the job runs at: 0, 7, 14, 21,hours and again at 0 hour on next day. So, After 21 hour the job is suppose to run at 4.00 hour on next day. But it runs at 0.00 hour.
I know it's possible to write a script to do the same. But I just want to know is there any method to set the cron to run the job at regular intervals.
Thanks in advance!
~Johnson
- 03-19-2008 #2
Hi,
I could be wrong, but I think */7 should do what you've described. The only thing that seems wrong is minute=*, it should be:
0 */7 * * * script.sh
- 03-20-2008 #3Just Joined!
- Join Date
- Aug 2007
- Posts
- 8
adrianx,
Thx for your reply. Yes that was a typo, I never meant that.
But, regarding */7 I have tested this in my Linux box. As I had informed in my previous post, the job runs at 0, 7, 14, 21,hours and again at 0 hour on next day. So, After 21 hour the job is suppose to run at 4.00 hour on next day. But it runs at 0.00 hour.
Any solutions appreciated.
Thanks,
~Johnson
- 03-21-2008 #4Just Joined!
- Join Date
- Feb 2007
- Posts
- 4
The behavior you're seeing from cron -- running at 0, 7, ... hours and then again with 0, 7, ... the next day -- is what you're supposed to see. AFAIK, there's no way to make cron do what you want.
You could have cron run your job every hour and have your job check the time before proceeding. Something like this psuedo-code:
-- get current time
-- figure total number of hours since some start time
-- if total hours mod 7 != 0:
-- exit
-- start doing real work now
Rick


Reply With Quote