每当我重新启动 apache2 时,Cronjob 就会消失

每当我重新启动 apache2 时,Cronjob 就会消失

我对 linux 和 apache 还比较陌生。

我通过以 root 身份登录然后输入来编辑 root 的 crontab,crontab -e但是每当我重新启动 apache2 服务器时,我的 cronjob 就会从 crontab 中消失。

有人可以向我解释一下吗?

答案1

哎呀!您已经发现 Ubuntu(Debian?)不是通过(即您使用 创建的文件)来处理rootcrontab ,而是通过 来处理,这为系统提供了更大的灵活性,并且通过略有不同的格式,能够以任何用户的身份运行定期作业。 /var/spool/cron/crontabs/rootcrontab -e/etc/crontab

/etc/crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

因此,放弃crontab -easroot并遵循/etc/crontab

我还没弄清楚为什么/var/spool/cron/crontabs/root会被删除,但由于这不是正确的方式,所以我认为这并不重要。

相关内容