Skip to content

Instantly share code, notes, and snippets.

@tegansnyder
Last active January 11, 2017 15:47
Show Gist options
  • Save tegansnyder/5dec8df1022abce1a59b to your computer and use it in GitHub Desktop.
Save tegansnyder/5dec8df1022abce1a59b to your computer and use it in GitHub Desktop.
Magento Scheduled Crons / Debugging Tips

Stock Magento Enterprise Cronjobs:

These indexers will run at the schedules list below automatically. No need to have a custom cron job setup. Keep indexers at "Update When Scheduled"

enterprise_targetrule_index_reindex
<cron_expr>0 * * * *</cron_expr>
enterprise_search_index_reindex_all
<cron_expr>0 3 * * *</cron_expr>
catalogrule_apply_all
<cron_expr>0 1 * * *</cron_expr>
sales_clean_quotes
aggregate_sales_report_order_data
aggregate_sales_report_shipment_data
aggregate_sales_report_invoiced_data
aggregate_sales_report_refunded_data
aggregate_sales_report_bestsellers_data
aggregate_sales_report_tax_data
<cron_expr>0 0 * * *</cron_expr>
core_clean_cache
<cron_expr>30 2 * * *</cron_expr>
enterprise_catalog_index_refresh_price
<cron_expr>0 * * * *</cron_expr>
enterprise_page_cache_crawler
<cron_expr>0 3 * * *</cron_expr>
catalog_product_index_price_reindex_all
<cron_expr>0 2 * * *</cron_expr>

Note: if I'm missing any let me know :)


Debuging Tips for Crons

Verifying Crond service is running

sudo service crond status
sudo service crond restart

Testing Crond Server

Add this to top of cron to test it if it is running. If it is you will get an email every 1 minute.

MAILTO="youremail@domain.com"
* * * * * echo testing

Debugging No Heartbeat Found

If you have Aoe_Scheduler installed you can try manually generating a heartbeat:

cd shell/
# generate a heartbeat manually
php scheduler.php -action runNow -code aoescheduler_heartbeat

Some other Aoe_Scheduler commands that might be helpful:

php scheduler.php -action listAllCodes
php scheduler.php -action lastRun -code aoescheduler_heartbeat -secondsFromNow
php scheduler.php -action scheduleNow -code aoescheduler_heartbeat

Debugging crons not running

If you are scratching your head trying to figure out why crons are not running it could be you have an existing cron process that is still running and needs to get killed. The cron.sh file that is used by magento checks the currently running processes, and if one already exists it quietly exits.

ps aux | grep "cron.sh"
# if you see one you can kill it
sudo kill -9 PIDNUMBER

Cron format is:

minute hour day month day-of-week
* * * * * -> Execute every minute
0 * * * * -> Execute every Hour
0 0 * * * -> Execute every mid-night
0 0 0 * * -> Execute every Month
0 0 0 0 * -> Execute every Weekday
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment