tl;dr: Does cron use the numerical value of an interval compared to the numerical value of the day to determine its time of execution or is it literally "every 3 days" at the prescribed time from creation?
If I add the following job with
crontab -e will it run at midnight tomorrow for the first time or three days from tomorrow? Or is it only on "third" days of the month? Day 1, 4, 7, 10...?
0 0 */3 * * /home/user/script.sh
I put this cron in yesterday and it ran this morning (that might be the answer to my question) but I want to verify that this is correct. Today is the 31st and that interval value does appear to fall into the sequence. If cron starts executing an interval on the 1st of the month, will it run again tomorrow for me?
There are already some excellent posts and resources about cron in general (it is a common topic I know) however the starting point for a specific interval isn't as clear to me. Multiple sources word it in multiple ways:
This unixgeeks.org post states:
Cron also supports 'step' values. A value of */2 in the dom field would mean the command runs every two days and likewise, */5 in the hours field would mean the command runs every 5 hours.
- So what is implied really by every two days?
This answer states that a cronjob of
0 0 */2 * *would execute "at 00:00 on every odd-numbered day (default range with step 2, i.e. 1,3,5,7,...,31)"
- Does cron always step from the first day of the month?
- It appears that the blog states the cron will execute on the 31st and then again on the 1st of the next month (so two days in a row) due to the interval being based on the numeric value of the day.
Another example from this blog post
0 1 1 */2 * command to be executedis supposed to execute the first day of month, every two months at 1am
- Does this imply that the cron will execute months 1,3,5,7,9,11?
It appears that cron is designed to execute interval cronjobs (
*/3) based on the numerical value of the interval compared to the numerical value of the day (or second, minute, hour, month). Is this 100% correct?
P.S. This is a very specific question about one particular feature of cron that (I believe) needs some clarification. This should allow Google to tell you, with 100% certainty, when your "every 3 months" cron will run for the first time after it's been added to crontab.