By Sean Delaney
Server: Ubuntu 12.04 Web Server: nginx PHP5-cli is installed.
I’ve edited /etc/crontab and added a new entry that executes a PHP script.
The cron job seems to be running fine but the PHP file isn’t doing anything.
I’ve check the permissions on the PHP file and they are set to 755.
The PHP file basically writes data to a TXT file and send an email. if I execute the PHP directly in the terminal, everything works as expected.
However, via the crontab, it doesn’t.
Here is the contents of my crontab:
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) */5 * * * * root /usr/bin/php /usr/share/nginx/html/functions/cron-test.php > /dev/null 2>&1
I’ve set the cron to run every 5 mins so I can check it is working…
If I run “grep CRON /var/log/syslog” in the terminal, I can see entries related to the cron entry.
Any ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Thanks sierra circle!
I ended up rebuilding the whole droplet again and this time cron jobs seem to work as expected.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.