Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
1. With varying end-of-month days you might get only 1 day between runs sometimes... /2 means every two days, so if the range is 1-31, that would be 1,3,5 ... 31 and then the job would run again on the first of the next month, only one day later.
2. I don't know if the "/" syntax is respected by all implementations of cron however. Check the crontab manual page in section 5 of the manual, i.e. to find out, do command:
Code:
man 5 crontab
Last edited by matthewg42; 10-09-2007 at 09:15 AM.
Oops, I didn't read far enough into the man page. The /2 (called 'stepping') should run the job at two day intervals, beginning on the second day of the month.
For months with an even number of days, that would work. For months with an odd number of days, that would probably result in a three day interval before the job runs again.
I'm not sure if /2 stepping on month day will end up with runs on 2, 4, 6 ... or 1, 3, 5 ...
The manual page is a little ambiguous about this. From the manual page it is clear that a range of 0-n/2 will result in even numbers 0, 2, 4, ... n; and for a range 1-n/2 there will be runs at 1,3,5 ... n.
What the * means is not well defined. For minutes in an hour it does state that */2 will start at 0, but there is never a day 0 of the month, so maybe */2 would mean 1,3,5... in that case. Only an experiment or examination of the source will tell. It may even vary according to which cron implementation is being used.
If someone knows for sure, either by looking at the source, or by an experiment, please post. If you do, please also post the cron implementation and version.
I use the default cron which comes with Ubuntu 7.04, and that is anacron 2.3. With this version using a day-of-month vale of */2 ran today - an odd-numbered day.
Perhaps to avoid this ambiguity, you should use "1-31/2" instead of "*/2".
Last edited by matthewg42; 10-09-2007 at 09:51 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.