一、atd与crond的区别
1.atd服务使用的at指令只能执行一次,而crond服务使用的crontab定义的命令,是循环作用的。
2.atd一般是只能作为临时任务应用,而crond一般是周期性任务,可重复应用。
3.依赖的服务不同,at对应的服务时atd,而crontab对应的服务时crond。
二 指定在2023/08/26 09:00将时间写入testmail.txt文件中
[root@server ~]# at 9:00 2022-08-26
at: refusing to create job destined in the past
--------拒绝创建过去的事情,所以写一个未来的时间 2024/08/26 9:00
[root@server ~]# at 9:00 2024-08-26
warning: commands will be executed using /bin/sh
at Mon Aug 26 09:00:00 2024
at> echo 'date' >testmail.txt
at> <EOT>
job 1 at Mon Aug 26 09:00:00 2024
三.指定在每天凌晨4:00将该时间点之前的系统日志信息备份到根目录下(/var/log/messages ),备份后日志文件名显示格式logfileYY-MM-DD :HH-MM
[root@server ~]# crontab -e
crontab: installing new crontab
[root@server ~]# crontab -l
0 4 * * * cp /var/log/messages /logfile`date +\%Y-\%m-\%d-\%H-\%M`