3

(OS is FreeBSD 8.1)

Yesterday I added 2 lines to crontab as root:

0 7 * * * curl --silent http://username:pass@dev.mydomain.tld/cron/execute/process/verbose/true >>/home/www/dev_mydomain_tld/logs/cron_process.log 2>&1
0 8 * * * curl --silent http://username:pass@dev.mydomain.tld/cron/execute/process/verbose/true >>/home/www/dev_mydomain_tld/logs/cron_process.log 2>&1

Doing the command right from shell as root works just fine. It just do some stuff, and send out some emails. The second run shouldn't send any emails, this is handled by the script. Thus the second line is only for my testing pleasure, making sure that a second run don't send out the same emails.

This morning I waited for the emails, at 7am and 8am - but nooo.

The cron log has the following to tell me

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:pass@dev.mydomain.tld/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:pass@dev.mydomain.tld/cron/execute/process/verbose/true >>/home/www/dev_mydomain_tld/logs/cron_process.log 2>&1)

Also /home/www/dev_mydomain_tld/logs/cron_process.log showed no change, also no change in date. Running from shell updates it just fine.

  • You should enable some sort of log rotation on your collected logfile so that it does not grow without bounds. – Phil Hollenback Feb 8 '11 at 9:12
  • @PhilHollenback Thanks for the tip, do you have any good resources on the subject? – Phliplip Feb 8 '11 at 13:50
  • Typically with freebsd you use newsyslog to rotate logs. Look at /etc/newsyslog.conf. Here's a page with some more info. – Phil Hollenback Feb 13 '11 at 8:25
6

Is curl in the path set by cron? You should either set your PATH in a script or use the full path to curl (ie /usr/local/bin/curl or similar).

Have a look at crontab(5) for the details about environnement variables.

| improve this answer | |
  • Yes i just found out reading another thread :) Thanks. – Phliplip Feb 8 '11 at 8:54
0

The main system crontab that root has access to (/etc/crontab) should have the user name as the sixth column. (Normal users' crontab files don't)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.