Setting up Magento cron jobs on managed hosting
Magento relies heavily on cron jobs to automate essential tasks such as reindexing, sending newsletters, generating sitemaps, and applying catalog price rules. On ruachost.com managed hosting, you must configure cron jobs correctly to ensure smooth store operation.
Why Cron Jobs Are Important
Section titled “Why Cron Jobs Are Important”- Automates background tasks (indexing, cache cleaning, scheduled emails).
- Keeps catalog price rules and promotions updated.
- Ensures reports, alerts, and feeds are generated on time.
- Prevents performance issues caused by manual task execution.
Configuring Cron Jobs in Magento 2
Section titled “Configuring Cron Jobs in Magento 2”-
Log in to cPanel on your managed hosting account.
-
Go to Advanced → Cron Jobs.
-
Delete the default cron job created by Softaculous (if present):
Terminal window 12,18,33,54 * * * * php /home/username/public_html/bin/magento cron:run > /dev/null(Replace
usernamewith your hosting account username.) -
Add the following new cron jobs (set to run every 15 minutes):
Magento main cron job
Section titled “Magento main cron job”Terminal window */15 * * * * /usr/local/bin/php /home/username/public_html/bin/magento cron:run | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' 2>&1 > ~/magento_cron.logMagento update cron job
Section titled “Magento update cron job”*/15 * * * * /usr/local/bin/php /home/username/public_html/update/cron.php | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' 2>&1 >> ~/magento_cron.logMagento setup cron job
Section titled “Magento setup cron job”*/15 * * * * /usr/local/bin/php /home/username/public_html/bin/magento setup:cron:run | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' 2>&1 >> ~/magento_cron.log -
Save the cron jobs.
-
Verify that output and error messages are logged in
~/magento_cron.log.
Configuring Cron Jobs in Magento 1.9 and Older
Section titled “Configuring Cron Jobs in Magento 1.9 and Older”-
Log in to Magento Admin.
-
Go to System → Configuration → Advanced → System → Cron (Scheduled Tasks).
-
Set the following values:
- Generate Schedules Every → 1
- Schedule Ahead for → 1
- Missed if Not Run Within → 30
- History Cleanup Every → 120
- Success History Lifetime → 120
- Failure History Lifetime → 120
-
Save configuration.
-
In cPanel, set a cron job to run every 4 hours:
0 */4 * * * php /home/username/public_html/cron.php
Important Notes
Section titled “Important Notes”- Magento is resource‑intensive; cron jobs should not run more frequently than every 15 minutes on managed hosting.
- Always replace
usernamewith your actual hosting account username. - Logs are stored in
~/magento_cron.logfor troubleshooting. - If cron jobs fail, check PHP paths and permissions.