Cron – What’s the best way to troubleshoot a cron that doesn’t fire

cron

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?

Best Answer

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?