Difference between revisions of "Setting Up a Cron Job"
Jump to navigation
Jump to search
(16 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
* Click on the (+) icon to add an item to the list. | * Click on the (+) icon to add an item to the list. | ||
* Press command+shift+G, type /usr/sbin/cron and press enter: | * Press command+shift+G, type /usr/sbin/cron and press enter: | ||
* Select the cron | * Select the cron executable and click Open | ||
==Vim Editor Commands== | |||
shift + : | |||
* :i // insert text | |||
* esc key // get out of insert mode | |||
* :wq Write file to disk and quit the editor | |||
== Setting up a Cron Job == | == Setting up a Cron Job == | ||
crontab -e | 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 -l | |||
crontab -r remove the current crontab file | |||
== Crontab sections == | == Crontab sections == | ||
Line 30: | Line 26: | ||
|- | |- | ||
|*||*||* ||*||* | |*||*||* ||*||* | ||
|- | |||
|0-59||0-23||1-31 ||1-12 or jan, feb,mar,..||0-6 or sun, mon, tue | |||
|} | |} | ||
{| class="wikitable" style="margin:auto" | |||
|Every Minute||* * * * *||Ever 5 Minute||*/5 * * * *||Ever 30 Minutes||*/30 * * * * | |||
|- | |||
|Every Hour||0 * * * *||Every Hour and 30 min||30 * * * *||Ever 2 hours||0 */2 * * * | |||
|} | |||
* 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 * * /scripts/backup.sh | |||
* 12 10-16/2 * | |||
*/ | |||
must be on a line by them self. | <p class="subhead">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.</p> | ||
<p class="subhead">Comments are allowed in crontabs, but they must be preceded with a '#', and must be on a line by them self. </p> | |||
---- | ---- | ||
==[[#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]]== |
Latest revision as of 15:03, 17 June 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
Vim Editor Commands
shift + :
- :i // insert text
- esc key // get out of insert mode
- :wq Write file to disk and quit the editor
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 |
Every Minute | * * * * * | Ever 5 Minute | */5 * * * * | Ever 30 Minutes | */30 * * * * |
Every Hour | 0 * * * * | Every Hour and 30 min | 30 * * * * | Ever 2 hours | 0 */2 * * * |
- 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 * * /scripts/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.