(OS是FreeBSD 8.1)
昨天我以root用户身份添加了2行到crontab:
0 7 * * * curl --silent http://username:[email protected]/cron/execute/process/verbose/true >>/home/www/dev_mydomain_tld/logs/cron_process.log 2>&1 0 8 * * * curl --silent http://username:[email protected]/cron/execute/process/verbose/true >>/home/www/dev_mydomain_tld/logs/cron_process.log 2>&1
在shell中以root身份执行命令可以正常工作。 它只是做一些东西,并发送一些电子邮件。 第二次运行不应该发送任何电子邮件,这是由脚本处理。 因此,第二行只是为了我的testing乐趣,确保第二次运行不发送相同的电子邮件。
今天早上,我在上午7点和上午8点等待电子邮件,但是没有。
cron日志有以下告诉我
Feb 8 07:00:00 webserver /usr/sbin/cron[50878]: (root) CMD ( /usr/local/bin/bsdsar_gather) Feb 8 07:00:00 webserver /usr/sbin/cron[50881]: (root) CMD (newsyslog) Feb 8 07:00:00 webserver /usr/sbin/cron[50882]: (root) CMD (/usr/libexec/atrun) Feb 8 07:00:00 webserver /usr/sbin/cron[50883]: (operator) CMD (/usr/libexec/save-entropy) Feb 8 07:00:00 webserver /usr/sbin/cron[50886]: (root) CMD (curl --silent http://username:[email protected]/cron/execute/process/verbose/true >>/home/www/dev_mydomain_tld/logs/cron_process.log 2>&1) [...] Feb 8 08:00:00 webserver /usr/sbin/cron[51147]: (root) CMD ( /usr/local/bin/bsdsar_gather) Feb 8 08:00:00 webserver /usr/sbin/cron[51149]: (root) CMD (newsyslog) Feb 8 08:00:00 webserver /usr/sbin/cron[51150]: (operator) CMD (/usr/libexec/save-entropy) Feb 8 08:00:00 webserver /usr/sbin/cron[51151]: (root) CMD (/usr/libexec/atrun) Feb 8 08:00:00 webserver /usr/sbin/cron[51152]: (root) CMD (curl --silent http://username:[email protected]/cron/execute/process/verbose/true >>/home/www/dev_mydomain_tld/logs/cron_process.log 2>&1)
另外/home/www/dev_mydomain_tld/logs/cron_process.log显示没有变化,date也没有变化。 从shell运行更新它就好了。
在cron设置的path中curl吗? 您应该在脚本中设置PATH或使用完整path来curl(即/ usr / local / bin / curl或类似)。
查看crontab(5)了解有关环境variables的详细信息。
根访问(/ etc / crontab)的主系统crontab应该有用户名作为第六列。 (普通用户的crontab文件不)