Linux学习日志:系统定时任务及延时任务,linux延时
Linux学习日志:系统定时任务及延时任务,linux延时
!! 定时任务是永久的 --->提前做好脚本,方便用时使用(无法跨年)
!! 延时任务是临时的
1. 延时任务
at命令
[root@localhost Desktop]# at 21:45 //在该时间执行该命令
at> touch file //命令
at>
job 1 at Mon Jan 22 21:45:00 2018 //当前共有一个命令
at.allow白名单与黑名单at.deny(默认不存在)
[root@localhost ~]# touch /etc/at.allow // 建立后/etc/at.deny失效,其他用户at权限被禁止
student
2. 定时任务
(1)命令设定方式
crontab -u 用户 -e //这个命令的文件是 /var/spool/cron/用户
分钟 小时 天 月 周
* * * * * //每分钟
*/2 * * * * //每2分钟
* 08-17* * * //每天早上8点到下午5点每分钟
* * 1,15* * //每月1号和15号每分钟
* * * 3 * //3月的每分钟
* * * * 4 //每个星期四的每分钟
crontab -u student -e 编辑
crontab -u student -l 查看
crontab -u student -r 删除
crontab -r 取消某用户的所有延时任务
(2)文件的设定方式(非交互)
[root@localhost Desktop]# echo "* * * * * student touch file" > /etc/cron.d/westos
3. 临时文件保管器
systemd-tmpfiles 位置 /lib/tmpfile.d/
systemd-tmpfiles --create
systemd-tmpfiles --clean
cd /lib/tmpfile.d/
d /westos 1777 root root 5s
目录 位置 权限 用户 用户组 多长时间内不能被删除
systemd-tmpfiles --create /lib/tmpfile.d/*
systemd-tmpfiles --clean /lib/tmpfile.d/*
cd /etc/cron. --->系统的临时文件
评论暂时关闭