linux循环调度,重识linux-循环执行的例行性工作调度

重识linux-循环执行的例行性工作调度

1 用户的设置

1)/etc/cron.allow  可以使用的账号,在这个文件内

2)/etc/cron.deny 不可以的放在这个文件里面

allow的优先级比deny的高,一般只使用1个

2 使用

crontab -e

每行是一个工作编辑

1)

59 23 1 5 * mail kiki < /home.lover.txt

数字范围

0-59 分钟    0-23 小时 1-31 日期 1-12 月份 0-7 周几 命令

特殊字符  * 表示任何都接受  /n 表示每隔N个单位

上面的意思就是

每年的5月1号23点59份 给kk发邮件

2) 每隔5分钟执行一次 命令

*/5 * * * * /home/test.sh

注:执行命令最好使用绝对路径

3)命令

crontab -l //列出任务

crontab -r //删除全部计划任务

3 系统的配置文件

crontab -e 是针对用户的

针对需要系统执行的命令,可直接执行

vim /etc/crontab

文件格式 和之前的类似

[root@instance-rglylh0b at]# cat /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

# For details seeman 4crontabs

# 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

是的,

1) 如果碰到多个同一时间段 执行的任务,可以设置时间段来执行

1,6,11 * * * * root CMD

每小时的1分钟 6分钟,11分钟 执行root的CMD命令

2)可以以周或者日,月为循环单位,但是不能是几月几号并且是星期几这种模式

4 可唤醒停机期间的工作任务

1)anacron  命令

2)

[root@instance-rglylh0b at]# cat /etc/anacrontab

#/etc/anacrontab: configuration file foranacron

# See anacron(8) and anacrontab(5) fordetails.

SHELL=/bin/shPATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

# the maximal random delay added to the base delay of the jobs

RANDOM_DELAY=45# the jobs will be started during the following hours only

START_HOURS_RANGE=3-22#periodin days delay in minutes job-identifier command1 5 cron.daily nice run-parts /etc/cron.daily7 25 cron.weekly nice run-parts /etc/cron.weekly

@monthly45 cron.monthly nice run-parts /etc/cron.monthly

关键期间未执行的任务,开机后调用  了解即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值