计划任务crontab
- 选项
OPTIONS
-u Append the name of the user whose crontab is to be tweaked. If this option
is not given, crontab examines "your" crontab, i.e., the crontab of the per-
son executing the command. Note that su(8) can confuse crontab and that if
you are running inside of su(8) you should always use the -u option for
safety?. sake. The first form of this command is used to install a new
crontab from some named file or standard input if the pseudo-filename "-" is
given.
// 用于设定某个用户的crontab服务
-l The current crontab will be displayed on standard output.
// 显示某个用户的crontab文件内容,如不指定用户则表示当前用户;
-r The current crontab will be removed.
// 从/var/spool/cron目录中删除某个用户的crontab文件。
-e This option is used to edit the current crontab using the editor specified
by the VISUAL or EDITOR environment variables. After you exit from the edi-
tor, the modified crontab will be installed automatically.
// 编辑某个用户的crontab文件内容,如不指定用户则表示当前用户
-i This option modifies the -r option to prompt the user for a ?./Y?. response
before actually removing the crontab.
// 在删除用户的crontab文件时给确认提示。
-s It will append the current SELinux security context string as an MLS_LEVEL
setting to the crontab file before editing / replacement occurs - see the
documentation of MLS_LEVEL in crontab(5).
- 语法
特殊字符代表意义
*(星号):代表任何时候都接受,day,month和week为“*”,表示无论那个月,那一天,周几,都在10点30分执行命令。
,(逗号):并列时间。举个例子:* 3,6,9,12 * * * command。意思是在3点,6点,9点或12点,执行命令。
-(减号):连续区间。举个例子:* 9-17 * * * command。上面的意思是从9点到17点,每一分钟都要执行这个任务
/n(斜线):n代表数组,表示每隔n个单位之间,比如每隔5分钟,可以写成下面:
*/5 * * * * command