1
votes

As the Magento documentation states, you need to set up a cron job on your web server in order to get things like order confirmation emails to send out, like so:

* * * * * /bin/sh /absolute/path/to/magento/cron.sh

This is a very simple cron job. The issue is, automated tasks are not completing in Magento. It's as if the script isn't being run by the cron job. And as a result, order confirmation emails are not sending (among all the other Magento automated tasks).

I've installed the AOE Scheduler extension to double-check every automated task in Magento and see when tasks are completing (or, in this case, when they're not). None of the tasks including core_email_queue_send_all are completing on the 1-minute-interval basis.

Now here's the weird part. If I just go run the cron.php script (cron.sh triggers cron.php) by loading it up in my web browser at mydomain.com/cron.php, the Magento automated tasks all execute! And since the script works like this when I run it manually, and I know cron jobs are working...I can't figure this out!

Please help!

ADDITIONAL DETAILS

Here's how I know cron jobs are working—I have tested cron jobs on my server by creating a PHP script that sends a basic email with mail(), and ran a similar cron job to the one above to execute it every minute—the cron job functions normally. I am also getting MAILTO emails from the server every time the cron job runs. No errors that I can see.

I can also execute this exact command in the cron job...

/bin/sh /absolute/path/to/magento/cron.sh

...in Terminal when I SSH in, and it runs the script successfully and Magento runs all automated tasks. It just doesn't run every minute in the cron job!

This is totally weird and I can't figure it out.... At the end of the day, all this work I did on this Magento store is moot if customer's can't check out and get confirmation emails.

Any advice would be extremely appreciated.

UPDATE

I was able to get by with using a wget command to call cron.php, but this still doesn't feel like a permanent solution.

wget -O /dev/null -q http://domain.com/cron.php

While it's technically working now, Magento's documentation specifically recommends running cron.sh, not cron.php. Still would love a concrete answer to why the cron job won't run cron.sh with sh.

2
Add first line of /home/[server_username]/public_html/cron.sh to your question.Cyrus

2 Answers

1
votes

Some steps I would be trying:

In terminal:

Check your cron log:

tail -f /var/log/cron

Can you see the commands being run?

Check if cronjobs are present:

crontab -l

Check if the cron user has executable permissions for the file, if not:

chmod +x file.sh

Is cron running? check to see if a process is running:

pgrep crond
1
votes

In case of errors you will get an email with the error recorded, but this needs configuration first. You can see the solution here https://www.phase2technology.com/blog/how-to-enable-local-smtp-server-postfix-on-os-x-leopard/

In this case this solution here helped me http://support.xtento.com/wiki/Setting_up_the_Magento_cronjob

My environment is OSX El Capitain with local mail postfix enabled to send cron status emails on a gmail account I set for testing orders in my Magento shop, MAMP for testing Magento locally and AOE Scheduler Magento extension installed and configured.

The code that worked for me is:

MAILTO="[email protected]"

curl -s -o /dev/null http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php /dev/null

I hope this helps someone as I lost almost 2 days getting the right settings. Good luck!