Difference between revisions of "Setting Up a Cron Job"
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
crontab -e ** use the -e switch, do not edit the file directly | crontab -e ** use the -e switch, do not edit the file directly | ||
crontab -l - shows scheduled jobs | crontab -l - shows scheduled jobs | ||
crontab -r remove the current crontab file | crontab -r remove the current crontab file | ||
Line 25: | Line 21: | ||
|*||*||* ||*||* | |*||*||* ||*||* | ||
|- | |- | ||
| | |0-59||0-23||1-31 ||1-12 or jan, feb,mar,..||0-6 or sun, mon, tue | ||
|} | |} | ||
Line 31: | Line 27: | ||
* minute of the hour the command will run on, and is between '0' and '59' | * minute of the hour the command will run on, and is between '0' and '59' | ||
*hour the command will run on, and is specified in the 24 hour clock, values must be between 0 and 23 (0 is midnight) | * hour the command will run on, and is specified in the 24 hour clock, values must be between 0 and 23 (0 is midnight) | ||
*Day of Month, that you want the command run on, e.g. to run a command on the 19th of each month, the dom would be 19. | * Day of Month, that you want the command run on, e.g. to run a command on the 19th of each month, the dom would be 19. | ||
*month a specified command will run on, it may be specified numerically (0-12), or as the name of the month (e.g. May) | * month a specified command will run on, it may be specified numerically (0-12), or as the name of the month (e.g. May) | ||
* the Day of Week that you want a command to be run on, it can also be numeric (0-7) or as the name of the day (e.g. sun). | * the Day of Week that you want a command to be run on, it can also be numeric (0-7) or as the name of the day (e.g. sun). | ||
* user who runs the command. | * user who runs the command. | ||
* command that you want run. This field may contain multiple words or spaces. | |||
* 12 10-16/2 * * root backup.sh | * 12 10-16/2 * * root backup.sh | ||
When using the names of weekdays or months, it isn't case sensitive, but only the first three letters should be used, e.g. Mon, sun or Mar, jul. | |||
When using the names of weekdays or months, it isn't case sensitive, but only | |||
the first three letters should be used, e.g. Mon, sun or Mar, jul. | |||
must be on a line by them self. | Comments are allowed in crontabs, but they must be preceded with a '#', and must be on a line by them self. | ||
---- | ---- | ||
==[[#Setting up a Cron Job|Back To Top]]-[[Main_Page| Home]] - [[Ubuntu_Tips|Category]]== | ==[[#Setting up a Cron Job|Back To Top]]-[[Main_Page| Home]] - [[Ubuntu_Tips|Category]]== |
Revision as of 14:49, 17 May 2024
Setting Cron to run on Mac Os
- Cron needs full disk access in order to run on mac
- Go to System Settings > Privacy & Security > Full Disk Access:
- Click on the (+) icon to add an item to the list.
- Press command+shift+G, type /usr/sbin/cron and press enter:
- Select the cron executable and click Open
Setting up a Cron Job
crontab -e ** use the -e switch, do not edit the file directly crontab -l - shows scheduled jobs crontab -r remove the current crontab file
Crontab sections
Minute | Hour | Day (month) | Month | Day (week) |
---|---|---|---|---|
* | * | * | * | * |
0-59 | 0-23 | 1-31 | 1-12 or jan, feb,mar,.. | 0-6 or sun, mon, tue |
- minute of the hour the command will run on, and is between '0' and '59'
- hour the command will run on, and is specified in the 24 hour clock, values must be between 0 and 23 (0 is midnight)
- Day of Month, that you want the command run on, e.g. to run a command on the 19th of each month, the dom would be 19.
- month a specified command will run on, it may be specified numerically (0-12), or as the name of the month (e.g. May)
- the Day of Week that you want a command to be run on, it can also be numeric (0-7) or as the name of the day (e.g. sun).
- user who runs the command.
- command that you want run. This field may contain multiple words or spaces.
- 12 10-16/2 * * root backup.sh
When using the names of weekdays or months, it isn't case sensitive, but only the first three letters should be used, e.g. Mon, sun or Mar, jul.
Comments are allowed in crontabs, but they must be preceded with a '#', and must be on a line by them self.