What is crontab?
The crontab command is the abbreviation of cron table. It is the configuration file of cron, also called the task list. We can find the relevant configuration files in the following directory
/var/spool/cron/: stores all user definitions to be executed regularly The task, the file name is consistent with the user name
/etc/crontab: Tasks to be performed periodically by the system
/etc/cron.d/: Directory used to store any crontab files or scripts to be executed
Other directories: /etc/ cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly, each represents the storage of tasks executed hourly, daily, weekly, and monthly
Usage of crontab
crontab [-u username] //可选,省略则表示操作当前用户的crontab -e //编辑crontab定时任务 -l //列出crontab里的内容 -r //删除crontab
crontab commands are composed of time and commands. The time is arranged in order by minutes, hours, days, months, and Fridays. The operators are:
*: any time
/:How often
-:Continuous time
,:Discontinuous time
Instance description
Execute the command every minute
* * * * * The command
is executed at the 10th and 30th minutes of every hour
10,30 * * * * Command
is executed every minute from 8 to 10 o'clock
* 8-10 * * * Command
is executed every 10 minutes on the 15th of every month
*/10 * 15 * * Order
is executed every Monday at 6:30
30 6 * * 1 Order