Continuing from a Stackoverflow question, I've got a .sh that tries to (1) run a script that sets environment vars and then (2) runs a php script.
The crontab entry (have tried with and without >>
output):
*/1 * * * * /home/user/public_html/domain.com/private/ec2-api-tools/php/doQueue.sh >> /home/user/output.txt
The script, doQueue.sh (running this by hand works):
#/bin/sh
. ./environment.sh
php process_queue.php
The environment.sh (again, works by hand):
#!/bin/sh
echo "running environment"
PATH=$EC2_HOME/bin:$PATH
EC2_HOME=/home/user/public_html/domain.com/private/ec2-api-tools
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/user/public_html/domain.com/private/ec2-api-tools/bin
MAIL=/var/mail/root
PWD=/home/user/public_html/domain.com/private/ec2-api-tools
JAVA_HOME=/usr/lib/jvm/java-6-sun/jre/
LANG=en_US.UTF-8
EC2_PRIVATE_KEY=/home/user/public_html/domain.com/private/ec2-api-tools/pk-hash.pem
EC2_CERT=/home/user/public_html/domain.com/private/ec2-api-tools/cert-hash.pem
I've tried variations using sh
and .
to no avail. What's the best way to troubleshoot this?
Make sure crontab file ends with a newline
Is this in
/var/spool/cron/crontabs/
or/etc/cron.d/
(the latter requires the user to run the job as)?Have you tried putting debug statements in doQueue.sh to get some output to verify that it's running?
!
And what is the CWD when the script runs? Try specifying the absolute path to environment.sh
That would explain why the cron job doesn't actually work, but not why it never fires at all.
By default, cron mails the local user with the output of jobs and error messages - have you checked this?
Are you sure that the job exists in the cron file? (i.e. what do you see when you type in 'crontab -l' at the prompt).
HTH
C.