**
一 延时任务
**
创建一个监控命令:
at 时间 ##设定在该时刻要进行什么操作
at now+数字min ##在几分钟后要进行什么操作
at -l ##查看该操作的编号(只能查看到最新建立但又未执行的操作)
at -c 3 ##查看编号为3要做什么操做(操作一旦执行便查看不到了)
at -r 3 ##撤回编号为3的操作
at黑白名单
二 定时任务
-e写的文件实际在/var/spool/cron/root/下
crontab -u root -e ##以root用户身份发起定时任务
crontab -u westos -e ##以westos用户身份发起定时任务
crontab -u root -l ##查看root用户的定时任务
crontab -u westos -l ##查看westos用户的定时任务
crontab -u root -r ##删除所有定时任务
systemctl restart crond.service ##启动服务定时任务生效
任务内容格式详解: 一般格式:时间+任务
时间的具体写法:
分钟 小时 天 月 周
-
* * * * ##每天每分钟
*/3 08,17 * * * ##每天的早上8点和下午的5点每隔3分钟
*/2 08-17 18 6 3 ##6月18日早上8点到下午的5点每隔2分钟
和6月每周的星期3
即:周和天是独立的
3 文件方式设定定时任务
vim /etc/cron.d/file
-
-
-
-
-
username action
-
-
-
-
-
-
-
-
-
root rm -fr /mnt/*
-
-
-
-
- 黑名单 /etc/cron.deny
##系统中默认存在,在文件中出现的用户不可以执行crontab
白名单 /etc/cron.allow
##系统中默认不存在,当文件出现,默认普通用户不可以执行crontab
##只有名单中的用户可以执行,并且黑名单 /etc/cron.deny失效
##这两个名单都不会影响/etc/cron.d/目录中定时任务的发起和执行
三、系统中临时文件的管理方式
cd /usr/lib/tmpfiles.d/
vim westos.conf ##创建文件名字必须.conf结尾
文件类型 名称 权限 所有人 所有组 存在时间
d /mnt/westos 777 root root 8s
systemd-tmpfiles --create /usr/lib/tmpfiles.d/* #creat 创建
systemd-tmpfiles --clean /usr/lib/tmpfiles.d/* #clean 清除
2. systemd-tmpfiles --create /usr/lib/tmpfiles.d/ #creat 创建*
3.systemd-tmpfiles --clean /usr/lib/tmpfiles.d/ #clean 清除*