计划任务:at 和 crontab 命令

# 计划任务:at 命令

service atd status

at 10242020

at> poweroff -f

at> xx

at> yy

at> <EOT>    <C-d 终止>

job 1 at Sat Oct 24 14:50:00 2020

at 10/24/2020

at now +10minutes    「 十分钟后 」 

at 1am tomorrow    「 明天上午1点 」 

at 4pm +3 days        「 三天后的下午4点 」 

atq 或 at -l     「 列表 」 

1    Sat Oct 24 14:50:00 2020 = root

5    Tue Oct 27 16:00:00 2020 a root

4    Sun Oct 25 01:00:00 2020 a root

3    Sat Oct 24 15:07:00 2020 a root

at -c [序号]    「 查询 」 

atrm [序号]  或 at -d [序号]   「 删除 」 

/etc/at.deny 「 黑明单 」 

/etc/at.allow    「 白名单 」 

 

# 计划任务:crontab 命令

crontab -l    「 列表 」 cat -n /var/spool/cron/root    「 地址 」 

*/1 * * * * /usr/sbin/ntpdate time.nist.gov >/tmp/cron.log 2>&1

*/10 * * * * /Data/code/shell/ping.sh www.sina.com&>>/tmp/ping.log

crontab -l -u Thomas

crontab -r 「 清空 」 

crontab -e    「 编辑

分           时    天            月    周        命令 

*              *      *              *      *             date        「 每分钟执行 」 

0             7      *              *     *             date        「 每天7点执行 」

0             7      *              *     1-5         date            「 每星期1-5的7点执行 」 

0-30/5    7      *               *     *             date        「 每天7点0-30分钟内,每5分钟执行一次 」 

30           9    1-10,15     2    *              date         「 2月的1-10号、15号的9:30执行一次 」          "分时天月”匹配

30           9    1-10,15     2    1,3,5        date            「 2月的1-10、15号 或者 2月的星期135的9:30执行一次 」  天或周

 

/etc/cron.deny    「 黑明单 」 

/etc/cron.allow    「 白名单 」 

/etc/crontab    「 系统计划任务 」 

# 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

echo xx `hostname` bb

echo xx $(hostname) bb

ls /etc/cron.{deny,monthly,daily,hourly,weekly}

# anacreon 恢复关机期间未运行的定时任务

cat /var/spool/anacron/cron.{daily,monthly,weekly}    「 anacron上次运行时间 」 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值