Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:base-system:cron [2021/02/10 03:40] – [Task specification] vgaetera | docs:guide-user:base-system:cron [2023/08/08 11:30] – Added my cronjob to keep last N snapshots of config torxgewinde | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Scheduling tasks ====== | + | ====== Scheduling tasks with cron ====== |
| {{section> | {{section> | ||
| ===== Introduction ===== | ===== Introduction ===== | ||
| - | * OpenWrt | + | * OpenWrt |
| - | * This how-to describes the methods | + | * This how-to describes the method |
| + | * See also [[docs: | ||
| - | ===== Web interface ===== | + | ===== Goals ===== |
| + | * Run programs or scripts at a specific time. | ||
| + | * Automate scheduled task management. | ||
| + | |||
| + | ===== Web interface | ||
| Set up cron jobs using web interface. | Set up cron jobs using web interface. | ||
| - | - Navigate to **[[http:// | + | - Navigate to **LuCI -> System -> Scheduled Tasks**. |
| - Edit the configuration and click the **Save** button. | - Edit the configuration and click the **Save** button. | ||
| - | ===== Command-line | + | ===== Command-line |
| Set up cron jobs using command-line interface. | Set up cron jobs using command-line interface. | ||
| Line 27: | Line 32: | ||
| This will edit the configuraion ''/ | This will edit the configuraion ''/ | ||
| - | :!: There should be a end-of-line | + | :!: There should be a EOL character on the last line of the crontab file. |
| Just leave an empty line at the end to be sure. | Just leave an empty line at the end to be sure. | ||
| Line 55: | Line 60: | ||
| :!: 0 (zero) is treated as Sunday. | :!: 0 (zero) is treated as Sunday. | ||
| - | If you set the day of the week to 7, busybox | + | If you set the day of the week to 7, BusyBox |
| - | Table of shortcuts: | + | **Table of shortcuts:** |
| ^ Shortcut ^ Equivalent ^ Description ^ | ^ Shortcut ^ Equivalent ^ Description ^ | ||
| - | | '' | ||
| | '' | | '' | ||
| | '' | | '' | ||
| Line 68: | Line 72: | ||
| | '' | | '' | ||
| | '' | | '' | ||
| + | |||
| + | :!: Time shortcuts are not enabled by default. Shortcuts require compiling busybox with FEATURE_CROND_SPECIAL_TIMES enabled in the busybox compile options. | ||
| ===== Troubleshooting ===== | ===== Troubleshooting ===== | ||
| Line 82: | Line 88: | ||
| * [[man> | * [[man> | ||
| * [[https:// | * [[https:// | ||
| - | * [[http:// | + | * [[http:// |
| ==== Periodic reboot ==== | ==== Periodic reboot ==== | ||
| Line 109: | Line 115: | ||
| There is usually no programmable circuitry to actually power off the unit. | There is usually no programmable circuitry to actually power off the unit. | ||
| '' | '' | ||
| - | |||
| - | However, a more flexible approach is to use use the [[packages: | ||
| - | |||
| - | <code bash> | ||
| - | opkg update | ||
| - | opkg install watchcat luci-app-watchcat | ||
| - | </ | ||
| ==== Periodic network restart ==== | ==== Periodic network restart ==== | ||
| Line 135: | Line 134: | ||
| 59 05 * * 1 / | 59 05 * * 1 / | ||
| # crontab must end with the last line as space or a comment | # crontab must end with the last line as space or a comment | ||
| + | </ | ||
| + | |||
| + | ==== Keep number of configs / snapshots of config ==== | ||
| + | To keep a number N of configurations/ | ||
| + | |||
| + | <code bash> | ||
| + | #Make a new backup/ | ||
| + | #01 00 * * * sysupgrade -b "/ | ||
| + | 01 00 * * * find "/ | ||
| </ | </ | ||