How would I set a cron job to run every 7 minutes between 7pm and 11pm?
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
this will run at 19:00, 19:07, 19:14, 19:21, 19:28, 19:35, 19:42, 19:49, 19:56, 20:00, 20:07 and so on. The count of 7 minutes will restart at minute 00 of every hour, because 7 is not an exact divisor of 60. This bring to an interval of 4 minutes between minute 56 and minute 00 of the next hour. Is this ok? Otherwise you need a slightly more complicate solution.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
OK, 7 PM is 19 Hours, 11 PM is 23 Hours.
A quick check of man crontab indicates that
Code:
# run every seven minutes between 7 pm and 11 pm
0,7,14,21,28,35,42,49,56 19-23 * * * command
Ya can't run every seven minutes 'case 60 is not equally divisible by 7, eh? So we're running at the top of the hour and every seven minutes thereafter except the gap between 56 and 0 (of the next hour).
Hope this helps some.
[EDIT]
Or, the "/7" method indicated above -- duh! forgot about that one...
[/EDIT]
[EDIT]
Duh! As colucix points out below, the hours need to be 19-22, not 23. Arrgghh!
[/EDIT]
Note that the % signs are escaped in the crontab entry, since they have a special meaning in crontab (please, see man 5 crontab for details). Moreover note that in both cases the job must run every minute.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.