2016-02-15 16:02:20 +00:00
|
|
|
# crontab
|
|
|
|
|
|
|
|
> Schedule cron jobs to run on a time interval for the current user.
|
2016-09-08 10:37:36 +01:00
|
|
|
> Job definition format: "(min) (hour) (day_of_month) (month) (day_of_week) command_to_execute".
|
2016-02-15 16:02:20 +00:00
|
|
|
|
|
|
|
- Edit the crontab file for the current user:
|
|
|
|
|
|
|
|
`crontab -e`
|
|
|
|
|
2019-07-09 18:27:00 +01:00
|
|
|
- Edit the crontab file for a specific user:
|
|
|
|
|
|
|
|
`sudo crontab -e -u {{user}}`
|
|
|
|
|
2016-02-15 16:02:20 +00:00
|
|
|
- View a list of existing cron jobs for current user:
|
|
|
|
|
|
|
|
`crontab -l`
|
|
|
|
|
|
|
|
- Remove all cron jobs for the current user:
|
|
|
|
|
|
|
|
`crontab -r`
|
2016-03-14 19:25:51 +00:00
|
|
|
|
2019-04-22 17:28:30 +01:00
|
|
|
- Sample job which runs at 10:00 every day (* means any value):
|
2016-09-07 18:40:11 +01:00
|
|
|
|
2019-04-22 17:28:30 +01:00
|
|
|
`0 10 * * * {{command_to_execute}}`
|
2016-09-07 18:40:11 +01:00
|
|
|
|
|
|
|
- Sample job which runs every minute on the 3rd of April:
|
|
|
|
|
2019-04-22 17:28:30 +01:00
|
|
|
`* * 3 Apr * {{command_to_execute}}`
|
2016-09-07 18:40:11 +01:00
|
|
|
|
2019-04-22 17:28:30 +01:00
|
|
|
- Sample job which runs a certain script at 02:30 every Friday:
|
2016-09-07 18:40:11 +01:00
|
|
|
|
2019-04-22 17:28:30 +01:00
|
|
|
`30 2 * * Fri {{/absolute/path/to/script.sh}}`
|