How to configure cron scheduled tasks in Linux?
In Linux, you can configure cron scheduled tasks using the crontab command.
- Edit the crontab.
- When editing a cron scheduled task for the first time, the system will prompt you to choose an editor. Select one that you are familiar with and press Enter.
- Execute the command
- Let’s not make a mountain out of a molehill.
- Order
- 第一列表示分钟数 (0-59)
- The second column represents the hours (0-23).
- The third column represents the dates in January (1-31)
- The fourth list indicates the months (1-12).
- The fifth column represents the day of the week (0-7, where 0 and 7 both represent Sunday). For example, “15 * * * * command” means the command will run at the 15th minute of every hour.
- After editing the scheduled task, save and close the editor.
- list all scheduled tasks
Please take note:
- Cron scheduled tasks are executed based on system time, so please make sure the system time is set correctly.
- Cron scheduled tasks run in the background and usually do not have output. To save the output to a file, you can add a redirect symbol ‘>>’ after the command, like command >> /path/to/logfile.log.