Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron 1

Status
Not open for further replies.

Johnsf

MIS
Apr 5, 2004
45
NZ
Hi,

I need to setup cron so that it runs a task at 7:15 am for the first time and then every 5 minutes after that till 7 pm.

I know how do set it up to do every 5 minutes between 7 am to 7 pm but am unable to figure out how to get it to run the task only at 7:15 am to start with.

Is this possible?

Thanks, John
 
Why not have two jobs, one for each quarter-past each hour in your time period, and the other for all other 5 minute intervals?
 
Why not have two jobs, one for each quarter-past each hour in your time period, and the other for all other 5 minute intervals?
Wouldnt that mean you have the same job running 2 times concurrently on 15,30,45,0?

___________________________________
[morse]--... ...--[/morse], Eric.
 
Hmm - early morning rubber brain, but not entirely wrong - why would it run every 15 minutes in an hour?

Something like this then, perhaps:

15,20,25,30,35,40,45,50,55 07 * * * <job>

15 08-18 * * * <job>

00,05,10,20,25,30,35,40,45,50,55 08-18 * * * <job>

00 19 * * * <job>

There are variants of the minute construct of course, but this should do the job. Might be wrong, but my mind's on the footie right now!
 
this is what you need I think.....

minute hour dom month dow user cmd
15-55/5,7-19,*,*,* <user> <cmd>

___________________________________
[morse]--... ...--[/morse], Eric.
 
As I said, Eric, there are variants of the minute construct (some of which I'm unaware of, I have to say), but wouldn't your version miss out all 00, 05 and 10 minutes between 8:00 am and 19:00?
 
yeah it would....sorry, not awake yet.....I guess you are gonna need two jobs:

15-55/5,7,*,*,* <user> <cmd>
*/5,8-19,*,*,* <user> <cmd>

Thats basically what you would need to do.....

The first one tells you to run the command in the period of 7:15 to 7:55, every five minutes.....

Then the second one kicks off at 8 o clock, telling it to run the command every five minutes during the hour until 19:00 hours.

___________________________________
[morse]--... ...--[/morse], Eric.
 
Agreed - and just about the same as mine above, except I for some inexplicable reason included the 15 mins past job as a separate entity. Are there supposed to be commas in your version?
 
NO. Sorry.....Lets try this one more time:

15-55/5 7 * * * <user> <cmd>
*/5 8-19 * * * <user> <cmd>


___________________________________
[morse]--... ...--[/morse], Eric.
 
And is <user> <command> supposed to be su - user -c "<command>" if running as root?

This could run and run, but have a good day - I'm goin' home!!
 
It would be:

15-55/5 7 * * * root cmd
*/5 8-19 * * * root cmd

Thats it.


___________________________________
[morse]--... ...--[/morse], Eric.
 
That works... thanks :) Im using pycron for Windows NT but the syntax stored in crontab is the same
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top