1区别是at只运行一次,crontab运行多次,at一般是临时任务,crontab是周期性任务。
2.
[root@server ~]# at 9:00 2023-7-21
warning: commands will be executed using /bin/sh
at> date >> /root/testmail.txt
at> <EOT>
job 1 at Fri Jul 21 09:00:00 2023
[root@server ~]# at -l
1 Fri Jul 21 09:00:00 2023 a root
[root@server ~]#
3.首先输入
[root@server ~]# crontab -e
然后
0 4 * * * root /bin/cp var/log/messages /var/log/messages/logfile`date+\%Y-\%m-\%d-\%H:\%M:\%S`
就完成了