Hello
I’ve tried to create a cron job with a curl to a specific page on my website. On that page, when loaded, it’s sending out an e-mail to some specific people. I’ve tested the script, and it’s working just as intended.
What I’ve done to enable my cron job is:
sudo crontab -e* 17 * * * curl http://url.com/cron/email to the file and savedWhat I tried to here was to make a cron job calling the url once a day at 5pm. For some reason this is never happening - not even at another time of the day, it’s like it’s never run.
What am I doing wrong?
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!
This question was answered by @aha:
One more tip for debugging: to see the logged results of the cron task you set up to run every minute, use
grep CRON /var/log/syslogto print out all the lines related to cron. You should see something like:CRON[2179]: (root) CMD (/usr/bin/curl http://url.com/cron/email)However - you are right, there is a big difference between running
curl http://url.com/cron/emailand visiting http://url.com/cron/email in the browser:When you visit http://url.com/cron/email in the browser, if it returns an HTML doctype, the browser will: A) Download the HTML, B) Download any Javascript, CSS, Images referenced in the HTML, C)Render the page, D)Execute all Javascript.
When you curl http://url.com/cron/email, it is just A) Downloading the HTML
So if the thing that causes the email send is executed via javascript on the page,
curling it will not help.
If you’re looking for a simpler cron job solution, you might consider webcron services like easycron.com which will load a specific URL at a given time.
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.