重启 Apache 的 Cron 作业

Lev*_*Lev 2 server cron apache2 12.04

Ubuntu 服务器 12.04。我用:

sudo crontab -e
* * * * * root /etc/init.d/apache2 restart > /dev/null 2>&1
sudo restart cron
Run Code Online (Sandbox Code Playgroud)

它不起作用。如何解决?谷歌中有这么多文档,我需要一种“真正的方式”。

wlr*_*r70 8

我假设您在第二条语句之后退出了 cron 选项卡。第三行在 crontab 中不起作用。Cron 应该重新加载自己。

您的 cron 选项卡的问题在于您将其设置为每天每小时的每分钟运行一次等。* 是什么意思,所有选项。

以 comun 格式查看此内容

` m - h  dom mon dow    command

* *   *   *   *       root /etc/init.d/apache2 restart > /dev/null 2>&1
Run Code Online (Sandbox Code Playgroud)

你需要

0  1  * * * root /etc/init.d/apache2 restart > /dev/null 2>&1
Run Code Online (Sandbox Code Playgroud)

这是每天第 1 小时的第 0 分钟。