linux-计划任务

计划任务

环境:ubuntu-16.04.4-server-amd64

crontab [-u user] file
crontab [ -u user ] [ -i ] { -e | -l | -r }
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
-i (prompt before deleting user's crontab)
无-u即root

规则语法格式:
以行为单位,一行一计划。
分 时 日 月 周 需要执行的命令
0-59 0-23 1-31 1-12 0-6 reboot
* 通配符;
/ 比如*/10,表示每10分钟执行一次;
- 区间分隔;
, 多个取值;比如想在1点,2点,4点各执行一次,则在时位置:1,2,4

crontab -e
* * * * * echo "hello linux" >> ~/temp1.txt
crontab: installing new crontab //存储退出后

/etc/cron.deny
/etc/cron.allow
同一用户名称同时在两个名单或同时不在都可编辑计划任务。

猜你喜欢

转载自www.cnblogs.com/dailycode/p/9382653.html