Cron/README.md

43 lines
941 B
Markdown
Raw Permalink Normal View History

2021-07-21 03:40:13 +00:00
# Cron
2021-07-21 03:44:03 +00:00
An overview of using Ubuntu's built in Cron system.
2021-07-21 04:06:53 +00:00
***
### Edit Cron
```sh
sudo nano /etc/crontab
2021-07-21 03:44:03 +00:00
```
2021-07-21 06:55:44 +00:00
### Auto Update & Upgrade & Reboot/Restart
```sh
22 2 * * * root /usr/bin/apt update -q -y >> /var/log/apt/automaticupdates.log
33 3 * * * root /usr/bin/apt upgrade -q -y >> /var/log/apt/automaticupdates.log
44 4 * * * root reboot
```
***
# Advanced Configs
Below is a template/guide to creating your own crontab scripts!
2021-07-21 04:06:53 +00:00
### Templates
```sh
2021-07-21 03:44:03 +00:00
[minute] [hour] [day_of_month] [month] [day_of_week] [user] [command_to_run]
* * * * * root /root/update.sh
```
| Field | Values allowed |
| --- | --- |
| Minute | 0 to 59 |
| Hour | 0 to 23 |
| Day of month | 1 to 31 |
| Month | 1 to 12 OR JAN to DEC |
2021-07-21 03:45:53 +00:00
| Day of week | 0 to 6 OR SUN to SAT |
| Special Syntax | Regular equivalent |
| --- | --- |
| @hourly | 0 * * * * |
| @daily | 0 0 * * * |
| @weekly | 0 0 * * 0 |
| @monthly | 0 0 1 * * |
| @yearly | 0 0 1 1 * |