Rsync cron的作品,但monit cron不

我运行一个14.04 Ubuntu服务器。 我想自动收到Monit电子邮件提醒。 键入/usr/bin/monitcron.sh作为根手动工作正常。 我试着用Rsync做crontesting。 克龙效果很好。 但是,一旦我用它为Monit,除了当我手动运行时,它不再工作了。

在我的monitcron.sh脚本中,有:

 #!/bin/bash service monit reload 

编辑:我试过/etc/init.d/monit reload 。 一样。 这手动工作,但不与cron。

在我的crontab -e -u root ,我尝试运行:

 * * * * * /usr/bin/monitcron.sh 

但没有运气。

任何想法或原因,为什么脚本适用于Rsync而不是Monit? 谢谢。

编辑:我的/var/log/syslog显示:

 Feb 20 21:42:01 www postfix/local[5289]: A7F742490E: to=<[email protected]>, orig_to=<root>, relay=local, delay=0.13, delays=0.09/0/0/0.03, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION") Feb 20 21:42:01 www postfix/qmgr[1151]: A7F742490E: removed Feb 20 21:43:01 www CRON[6074]: (root) CMD (/usr/bin/monitcron.sh) Feb 20 21:43:01 www postfix/pickup[6069]: B71782490E: uid=0 from=<root> Feb 20 21:43:01 www postfix/cleanup[5111]: B71782490E: message-id=<[email protected]> Feb 20 21:43:01 www postfix/qmgr[1151]: B71782490E: from=<[email protected]>, size=603, nrcpt=1 (queue active) Feb 20 21:43:01 www postfix/local[5289]: B71782490E: to=<[email protected]>, orig_to=<root>, relay=local, delay=0.12, delays=0.05/0/0/0.07, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION") Feb 20 21:43:01 www postfix/qmgr[1151]: B71782490E: removed Feb 20 21:44:01 www CRON[6085]: (root) CMD (/usr/bin/monitcron.sh) Feb 20 21:44:01 www postfix/pickup[6069]: C79642490E: uid=0 from=<root> Feb 20 21:44:01 www postfix/cleanup[5111]: C79642490E: message-id=<[email protected]> Feb 20 21:44:01 www postfix/qmgr[1151]: C79642490E: from=<[email protected]>, size=603, nrcpt=1 (queue active) Feb 20 21:44:01 www postfix/local[5289]: C79642490E: to=<[email protected]>, orig_to=<root>, relay=local, delay=0.13, delays=0.06/0/0/0.07, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION") Feb 20 21:44:01 www postfix/qmgr[1151]: C79642490E: removed Feb 20 21:45:01 www CRON[6097]: (root) CMD (/usr/bin/monitcron.sh) Feb 20 21:45:01 www postfix/pickup[6069]: D64EA2490E: uid=0 from=<root> Feb 20 21:45:01 www postfix/cleanup[5111]: D64EA2490E: message-id=<[email protected]> Feb 20 21:45:01 www postfix/qmgr[1151]: D64EA2490E: from=<[email protected]>, size=603, nrcpt=1 (queue active) Feb 20 21:45:01 www postfix/local[5289]: D64EA2490E: to=<[email protected]>, orig_to=<root>, relay=local, delay=0.11, delays=0.04/0/0/0.07, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION") Feb 20 21:45:01 www postfix/qmgr[1151]: D64EA2490E: removed} 

编辑: https : //www.youtube.com/watch?v = j00517Nq9uo这个video告诉我,如果我想运行“服务Apache2重装”,我的脚本应该存储在/ var / www /。 有用。 以前我试过/ usr / bin /但是没有工作。 既然Apache2脚本正在工作,问题依然存在:应该在哪里运行Monit脚本('service monit reload')呢?

问题解决:我确定这是一个path问题。 我在脚本中添加了这样的path:#!/ bin / bash PATH = / sbin:/ bin:/ usr / sbin:/ usr / bin服务monit reload

我在这里find了解决scheme: https : //unix.stackexchange.com/questions/180342/running-init-d-script-produces-start-stop-daemon-not-found

感谢Ben Whaley的贡献和他的工作人员的帮助。