crontab Scheduled Tasks 1. Command Format
Usage: crontab [-u user] file crontab [-u user] [-e |-L |-R] (defaultis1003.2) -E (Edit user's crontab) -L (list user' s crontab) -R (delete user's crontab)-I (Prompt before Deleting user's crontab) -S (selinux context)
2. Command parameters
- -u user to set a user's crontab service
- The name of the file command. Use file as the Crontab task list file and load into crontab. If this file is not specified on the command line, the crontab command will accept the commands typed on the standard input (keyboard) and load them into crontab.
- -e Edit the contents of a user's crontab file. If you do not specify a user, the crontab file for the current user is edited.
- -L Displays the contents of a user's crontab file, and if no user is specified, displays the contents of the crontab file for the current user.
- -R Deletes a user's crontab file from the/var/spool/cron directory and, if you do not specify a user, deletes the current user's crontab file by default.
3.crontab file format
[Email protected] ~]# cat/etc/Crontabshell=/bin/bash <==which shell interface path to use=/sbin:/bin:/usr/sbin:/usr/bin <==Execute File search path mailto=root <==If there is an extra stdout, send the information to who # Example of Job definition:# by email.----------------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
0 * * * mail-s "at" Dmtsai </HOME/DMTSAI/.BASHRC #分 theSun and Moon week |<============== instruction string =========== =============>|
Special characters:
* (asterisk): The meaning of acceptance at any moment. (0 12 * * * The instruction is executed at 12:00 of the day of the week regardless of the month )
, (comma): Splits the time period. (instructions will be executed at 0 3,6 * * * 3:00 and 6:00)
-(minus): a time frame. (20 8-12 * * * 8 to 12 points each hour of 20 minutes to execute instructions)
/num (slash): num represents the number, which is the meaning of every num unit interval. (*/5 * * * * * Every five minutes to execute a command)
One Linux command per day