Portal Home > Knowledgebase > Articles Database > Bi-Weekly Cron


Bi-Weekly Cron




Posted by NuPixel, 10-09-2009, 04:10 PM
Anyone know how to get a cron to run twice a week? I want this email script to send out the same email twice a week, but am not sure which cron settings I should use.

Posted by nomankhn, 10-09-2009, 04:38 PM
Hello sir, cron have format like that, please check it accordingly. minute hour day month dayofweek command * minute — any integer from 0 to 59 * hour — any integer from 0 to 23 * day — any integer from 1 to 31 (must be a valid day if a month is specified) * month — any integer from 1 to 12 (or the short name of the month such as jan, feb, and so on) * dayofweek — any integer from 0 to 7 where 0 or 7 represents Sunday (or the short name of the week such as sun, mon, and so on) * command — the command to execute. The command can either be a command such as ls /proc >> /tmp/proc or the command to execute a custom script that you wrote. For any of the above values, an asterisk (*) can be used to specify all valid values. For example, an asterisk for the month value means execute the command every month within the constraints of the other values. A hyphen (-) between integers specifies a range of integers. For example, 1-4 means the integers 1, 2, 3, and 4. A list of values separated by commas (,) specifies a list. For example, 3, 4, 6, 8 indicates those four specific integers. The forward slash (/) can be used to specify step values. The value of an integer can be skipped within a range by following the range with /. For example, 0-59/2 can be used to define every other minute in the minute field. Step values can also be used with an asterisk. For instance, the value */3 can be used in the month field to run the task every third month. Any lines that begin with a hash mark (#) are comments and are not processed. Examples of crontabs # record the memory usage of the system every monday # at 3:30AM in the file /tmp/meminfo 30 3 * * mon cat /proc/meminfo >> /tmp/meminfo # run custom script the first day of every month at 4:10AM 10 4 1 * * /root/scripts/backup.sh

Posted by NuPixel, 10-09-2009, 05:17 PM
Okay cool, so basically for this I just set the script to run on two different days of the week..? Sounds simple enough.

Posted by nomankhn, 10-09-2009, 11:40 PM
Yes it is

Posted by DJMizt73, 10-11-2009, 01:42 AM
8 * * /my/script.sh #run 8 times a month



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Burst down again ? (Views: 843)
which is better (Views: 708)


Language: