Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

EDIT:

i am getting a 406 error page with this cron!

here is the crontab (copied from cPanel):

    * * * * * GET https://abc.com/cron/sendBulletinEmails.php >>
/home/abc/public_html/cron/logs/sendBulletinEmails.log

here is the log:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /cron/sendSurveyEmails.php could not be found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

here is my crontab:

* * * * * { cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} | /usr/bin/logger -t sendQueuedEmails

i am running ubuntu.

i am not seeing any logs in:

/var/log/cron
/var/log/messages
/var/mysql/log

where can it be?

share|improve this question
add comment

3 Answers

grep "CRON" /var/log/syslog

share|improve this answer
    
i get: Aug 6 10:33:01 fiqsrv1 CRON[25527]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} | /usr/bin/logger -t sendQueuedEmails) Aug 6 10:34:01 fiqsrv1 CRON[25533]: (cgurnik) CMD ({ cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} | /usr/bin/logger -t sendQueuedEmails) but where are the errors and where is the output? –  Garrett Aug 6 '10 at 14:36
add comment

It should be noted that A) you're not redirecting standard error. So if your scripts are bombing, the errors won't result in the messages file. So put a 2>&1 before the pipe. B) Cron doesn't have squat for environment variables. Are you sure your php script is actually working? There's a good chance it's choking, and hence why there's no output. Try sourcing in your login script like so: . /home/user/.bashrc


--Christopher Karel

share|improve this answer
    
i now have: * * * * * { cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} 2>&1 | /usr/bin/logger -t sendQueuedEmails but i don't understand (B). how do i source in my login script? –  Garrett Aug 6 '10 at 15:23
    
Add . /home/username/.bashrc at the start of the script. The . (period and a space) tells the script to reference that file for environment variables. If you're not using bash, you'll have to use the appropriate login script for that shell. (.kshrc, .profile, etc) –  Christopher Karel Aug 6 '10 at 19:07
    
i'm getting a 'bad minute' when i add that =S i am running bash. . /home/cgurnik/.bashrc * * * * * { cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} 2>&1 | /usr/bin/logger $ –  Garrett Aug 6 '10 at 20:16
    
Nono, sorry. Add it to the start of the script you're trying to call. In this case, since it's PHP...I don't know how that might be handled. (Sorry, I totally didn't notice that at first. Perhaps wrap this whole thing in a single bash script?) Are you certain that your script is actually doing anything? Furthermore, is that cd actually resulting in your script being run from the right location? Perhaps try outputting to a file, rather than using logger? Essentially, try and pin down where things aren't working, rather than the chain of commands at once. –  Christopher Karel Aug 6 '10 at 20:43
add comment
up vote 0 down vote accepted

it wasn't logging anything. after using GET in my cron (thanks to this answer), i append the output to a log file, like so:

* * * * * GET http://localhost/cron/sendQueuedEmails.php >> /var/www/cron/logs/sendQueuedEmails.log
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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