1. Edit the Scheduled task list using the CRONTAB-E command
The list of scheduled tasks edited with this command is user-level, and a file with the same user name is generated in the/var/spool/cron directory after the first edit, and the file content is our scheduled task list. If there is no scheduled task, this file is an empty file.
The crontab command also has some other options
-U #指定哪个用户的cron服务, which is typically required when the root user executes this command
-l #列出用户的定时任务列表, default current user
-R #删除用户的定时任务列表, default current user
-e #编辑用户的定时任务列表, default current user
Example: List of cron services for xiaoming users
Crontab-u xiaoming-l
2. Edit the/etc/crontab file directly with the following command:
Vim/etc/crontab
We will see the contents of the file as follows:
shell=/bin/Bashpath=/sbin:/bin:/usr/sbin:/usr/Binmailto=Roothome=/# for details seeMans 4crontabs# Example of Job definition:#.----------------Minute (0- -)# | .-------------Hour (0- at)# | | .----------Day of Month (1- to)# | | | .-------Month (1- A) OR jan,feb,mar,apr ... #| | | | .----Day of Week (0-6) (sunday=0Or7) OR sun,mon,tue,wed,thu,fri,sat#| | | | |# * * * * * * user-name command to be executed
The scheduled tasks for this configuration are at the system level.
3. Recommendations
It is generally recommended that you use CRONTAB-E so that the system will also help check the scripting syntax of our configuration.
Linux Add timed tasks, the difference between the CRONTAB-E command and the direct edit/etc/crontab