![]() As there are months having 31 days, some jobs are not run exactly every 2 days if we use method 1 above. Let’s take an example to illustrate the idea. So you can make the command run every day/week/month while use a test statement to control whether to really run the command. The command executed for a cron job is a piece of shell code. Method 2: use a test statement to control whether to really run the command If you need to make sure your cron job is run exactly every two N, check the other methods. For months, it is every two months in a year. For days, it is every two days in a month. To run the command every two months at 1:00 on the first day of the month, the crontab is 0 1 1 */2 * command to be executedīut please be aware that the every two N here is not exactly every two N. Check the crontab man page for more details about ranges and steps of crontab. This can be the easiest method if the job is intended to be run every two N in a range such as N is “day” and the range is “days in a month”. Crontab provides some extensions to support this: ranges can include “steps” like /2.
0 Comments
Leave a Reply. |