Well, I found the solution, although it IS a bit weird!
I was reading this article:
http://net.tutsplus.com/tutorials/other/scheduling-tasks-with-cron-jobs/
And I noticed the part about the bracket ( > ) to write to a log file. I changed the PHP file to not have the hash-bang declaration in the beginning, and put the parser path in the cronjob line instead. So now, my cron job looks like this:
[code]
40 11 * * * /usr/bin/php /home/jshaw/retireevents.php >> /home/jshaw/cron.log
[/code]
And I just got an email from the PHP script, meaning it ran like it should!
I guess the cronjobber was looking for a bracket or two to signify the end of the file/path declaration.
Please help me with my cron job. Immense details inside.
-
- Retired Moderator
- Posts: 18276
- Joined: 2006/12/13 20:15:34
- Location: Tidewater, Virginia, North America
- Contact:
Re: Please help me with my cron job. Immense details inside.
[quote]
Kinsbane wrote:
...
I guess the cronjobber was looking for a bracket or two to signify the end of the file/path declaration.[/quote]
Don't think that's the trick as I have never used redirection like that on the command line with cron, so it is definitely not required. Normally cron generates an email if and only if any output is produced. What you have done will redirect stdout to append to the log file. Anything going to stderr should still result in an email from cron to the owner of the crontab. If you want stderr to go to the log, append 2>&1 to the line.
I expect the real trick had something to do with getting rid of the shell script, but that's strange because I frequently use shell scripts (sometimes with redirection inside the script) with cron. Does the following work?[code]40 11 * * * /usr/bin/php /home/jshaw/retireevents.php[/code]?
Kinsbane wrote:
...
I guess the cronjobber was looking for a bracket or two to signify the end of the file/path declaration.[/quote]
Don't think that's the trick as I have never used redirection like that on the command line with cron, so it is definitely not required. Normally cron generates an email if and only if any output is produced. What you have done will redirect stdout to append to the log file. Anything going to stderr should still result in an email from cron to the owner of the crontab. If you want stderr to go to the log, append 2>&1 to the line.
I expect the real trick had something to do with getting rid of the shell script, but that's strange because I frequently use shell scripts (sometimes with redirection inside the script) with cron. Does the following work?[code]40 11 * * * /usr/bin/php /home/jshaw/retireevents.php[/code]?
-
- Posts: 1478
- Joined: 2006/05/29 16:50:11
- Location: San Francisco, CA
Re: Please help me with my cron job. Immense details inside.
Glad it's working for you! I don't think it was the redirect to a log file that made it work, but it's still great that the problem is solved.
- AlanBartlett
- Forum Moderator
- Posts: 9345
- Joined: 2007/10/22 11:30:09
- Location: ~/Earth/UK/England/Suffolk
- Contact:
Re: Please help me with my cron job. Immense details inside.
I'm seconding [b]Michael[/b]'s & [b]Phil[/b]'s comments.
With luck, after all the scratching, I've still got some "head fur" left. :roll:
With luck, after all the scratching, I've still got some "head fur" left. :roll: