Linux 更改 crontab 文件后重新启动 cron?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10193788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Restarting cron after changing crontab file?
提问by bArmageddon
Do I have to restart cron after changing the crontable file?
更改 crontable 文件后是否必须重新启动 cron?
采纳答案by leonbloy
No.
不。
From the cron man page:
从cron 手册页:
...cron will then examine the modification time on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified
...cron 然后将检查所有 crontab 上的修改时间并重新加载那些已更改的。因此,无论何时修改 crontab 文件,都不需要重新启动 cron
But if you just want to make sure its done anyway,
但如果你只是想确保它完成了,
sudo service cron reload
or
或者
/etc/init.d/cron reload
回答by Sheldmandu
On CentOS with cPanel sudo /etc/init.d/crond reload
does the trick.
在 CentOS 上使用 cPanelsudo /etc/init.d/crond reload
可以解决问题。
On CentOS7: sudo systemctl start crond.service
在 CentOS7 上: sudo systemctl start crond.service
回答by jono
Try this out: sudo cron reload
It works for me on ubuntu 12.10
试试这个:sudo cron reload
它在 ubuntu 12.10 上对我有用
回答by Tit Petric
Depending on distribution, using "cron reload" might do nothing. To paste a snippet out of init.d/cron (debian squeeze):
根据发行版的不同,使用“cron reload”可能什么都不做。从 init.d/cron 中粘贴一个片段(debian 挤压):
reload|force-reload) log_daemon_msg "Reloading configuration files for periodic command scheduler" "cron"
# cron reloads automatically
log_end_msg 0
;;
Some developer/maintainer relied on it reloading, but doesn't, and in this case there's not a way to force reload. I'm generating my crontab files as part of a deploy, and unless somehow the length of the file changes, the changes are not reloaded.
一些开发人员/维护人员依赖它重新加载,但没有,在这种情况下,没有办法强制重新加载。我正在生成我的 crontab 文件作为部署的一部分,除非文件的长度以某种方式发生变化,否则不会重新加载更改。
回答by Gyro
I had a similar issue on 16.04 VPS Digital Ocean. If you are changing crontabs, make sure to run
我在 16.04 VPS Digital Ocean 上遇到了类似的问题。如果您要更改 crontabs,请确保运行
sudo service cron restart
回答by Flair
try this one for centos 7 : service crond reload
在 centos 7 上试试这个:service crond reload
回答by ako
Try this: service crond restart
, Hence it's crond
not cron
.
试试这个:service crond restart
,因此它crond
不是cron
。
回答by Mawty
There are instances wherein cron needs to be restarted in order for the start up script to work. There's nothing wrong in restarting the cron.
在某些情况下,需要重新启动 cron 才能使启动脚本正常工作。重新启动 cron 没有任何问题。
sudo service cron restart
须藤服务 cron 重启
回答by vebmaster
1) If file /var/spool/cron/crontabs/root
edit via SFTP client - need service cron restart
.
Reload service not work.
1) 如果/var/spool/cron/crontabs/root
通过 SFTP 客户端编辑文件- 需要service cron restart
. 重新加载服务不起作用。
2) If edit file /var/spool/cron/crontabs/root
via console linux (nano, mc) - restart NOT need.
2) 如果/var/spool/cron/crontabs/root
通过控制台 linux (nano, mc)编辑文件- 不需要重新启动。
3) If edit cron via crontab -e
- restart NOT need.
3)如果通过crontab -e
- 重新启动不需要编辑cron 。
回答by Aqua Huang
Ubuntu 18.04 * Usage: /etc/init.d/cron {start|stop|status|restart|reload|force-reload}
Ubuntu 18.04 * 用法:/etc/init.d/cron {start|stop|status|restart|reload|force-reload}