The crontab command is used to set instructions to be executed periodically. It is common in Unix and Linux operating systems. This command can read instructions from the standard input device and store them in the "crontab" file for later reading and execution; the syntax is "crontab option UserName|file".
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
The crontab command is common in Unix and Linux operating systems and is used to set instructions to be executed periodically.
This command reads instructions from the standard input device and stores them in the "crontab" file for later reading and execution. (Recommended learning: Linux video tutorial)
In the Linux system, Linux task scheduling work is mainly divided into the following two categories:
1. System execution Work: work that the system performs periodically, such as backing up system data, cleaning cache
2. Work performed by individuals: work that a user has to do regularly, such as checking whether the mail server is available every 10 minutes Xinxin, these tasks can be set by each user.
System scheduled tasks are generally stored in the file /etc/crontab, which contains some system running schedulers. We can view them through commands Take a look at the content inside:
[root@xiaoluo ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed
The syntax of the crontab command is:
crontab [-e [UserName]|-l [UserName]|-r [UserName]|-v [UserName]|File ]
Note: crontab is used to allow users to It is used to execute programs at fixed times or fixed intervals. In other words, it is similar to the user's schedule. -u user refers to setting the schedule of the specified user. The premise is that you must have its permissions (for example, root) to specify other people's schedules. If -u user is not used, it means setting your own schedule.
Description of each parameter:
-e [UserName]: Execute the text editor to set the schedule, the default text editor Yesvi
Linux Operation and Maintenance Tutorial column to learn!
The above is the detailed content of What is the usage of crontab command under linux. For more information, please follow other related articles on the PHP Chinese website!