[root@server ~]# at 9:00 2023-04-15
at: refusing to create job destined in the past #时间已经过了
[root@server ~]# at 9:00 2024-04-15
warning: commands will be executed using /bin/sh
at Mon Apr 15 09:00:00 2024
at> echo'date' >>root/testmail.txt
at> <EOT>
job 12 at Mon Apr 15 09:00:00 2024
[root@server ~]# vim /etc/crontab
0 4 0 0 0 root /bin/cp /var/log/messages /backup/logfile`date +\%Y-\%m-\%d-\%H:\%M`
为了验证我们换成每一分钟看是否成功:
* * * * * root /bin/cp /var/log/messages /backup/logfile`date +\%Y-\%m-\%d-\%H:\%M`
[root@server backup]# cd /backup/
[root@server backup]# ls
logfile2024-01-22-16:45:01 logfile2024-01-22-16:47:01
logfile2024-01-22-16:46:01 logfile2024-01-22-23:16
时间变动成功,把自己想要的时间改回来即可