此 cron 作业已停止运行。它上次运行是在 9 月 27 日。
# Empty trash every 120 minutes
*/120 * * * * /home/andy/bin/emptytrash60.sh
内容emptytrash120.sh
:
Trash_Log=/home/andy/Downloads/Trash_log.txt
trash-empty
date +"%m-%d-%Y-%I:%M" >> $Trash_Log
echo "Trash has been emptied." >> $Trash_Log
#rm $Trash_Log
我该如何诊断到底发生了什么?
输出stat /home/andy/bin/emptytrash120.sh
:
File: /home/andy/bin/emptytrash120.sh
Size: 250 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 772 Links: 1
Access: (0775/-rwxrwxr-x) Uid: ( 1000/ andy) Gid: ( 1000/ andy)
Access: 2022-09-29 05:28:30.191747869 -0500
Modify: 2022-09-29 05:28:24.303820397 -0500
Change: 2022-09-29 05:28:24.351819806 -0500
Birth: -
答案1
由于您显然更改了文件的名称,请尝试在 crontab 中进行以下设置:
# Empty trash every 2 hours
0 */2 * * * /home/andy/bin/emptytrash120.sh
这个语法对于 cron 来说应该更可行。