Optimising Magento cron jobs on shared hosting

Magento's default cron settings run jobs every minute, which can overload a shared hosting account and slow down other accounts on the same server. Reducing the frequency and adjusting a few settings in Magento's admin panel fixes this without affecting your store's functionality.

Why the default Magento cron settings cause problems

Magento documentation recommends running cron every minute. On shared hosting this is rarely necessary and can cause issues, because every run loads the full Magento framework and scans the cron schedule table for pending jobs.

If jobs overlap or the schedule table grows too large, cron runs can pile up and never finish, which uses excessive CPU and memory. This is the most common cause of "cron overload" reports on Magento stores. On many managed hosting environments, cron intervals shorter than 15 minutes are automatically reset to 15 minutes for exactly this reason, so running cron every 1–5 minutes rarely makes sense on a shared account.

Step 1: adjust cron settings in the Magento admin panel

These steps apply whether your hosting account uses cPanel or DirectAdmin, as they are done inside Magento itself.

  1. Log in to Magento using your administrator account.
  2. On the top menu bar, click System, then click Configuration.
  3. In the left-hand Configuration panel, scroll to Advanced and click System.
  4. Click Cron (Scheduled Tasks).
  5. In Generate Schedules Every, type 5.
  6. In Schedule Ahead for, type 5.
  7. In Missed if Not Run Within, type 30.
  8. In History Cleanup Every, type 120.
  9. In Success History Lifetime, type 120.
  10. In Failure History Lifetime, type 120.
  11. Click Save Config.

Shortening the history lifetime values stops the cron schedule table growing too large, which keeps each cron run fast. For stores with heavy traffic, consider running resource-intensive tasks such as indexing in a separate cron group, using bin/magento cron:run --group=index, so they don't block lighter jobs like email sending.

Step 2: edit the server-side cron job

Once Magento's own settings are adjusted, update the actual cron job that triggers bin/magento cron:run on the server. The steps differ depending on your control panel.

cPanel

  1. Log in to cPanel.
  2. In the Advanced section, click Cron Jobs.
  3. Under Current Cron Jobs, find the Magento cron job and click Edit.
  4. In the Minute field, type */5.
  5. In the Hour, Day, Month and Weekday fields, type *.
  6. Click Edit Line to save. The new schedule takes effect immediately.

If you don't want an email notification every time the job runs, leave the notification email field blank or append >/dev/null 2>&1 to the end of the command.

DirectAdmin

  1. Log in to DirectAdmin.
  2. Go to Advanced Features, then click Cron Jobs.
  3. Click Create Cron Job (or edit the existing Magento entry if one is listed).
  4. Set the schedule to every 5 minutes, for example by entering */5 in the minute field and * in the other time fields.
  5. In the Command field, enter the full path to the PHP binary followed by the path to bin/magento cron:run, for example /usr/local/bin/php /home/username/public_html/bin/magento cron:run. Check your exact PHP path and installation folder in the client area at my.hostking.host if you're unsure.
  6. Click Prevent Email if you don't want a notification email for every run.
  7. Click Create to save the cron job.

DirectAdmin cron jobs run from the server's root directory, not from public_html. Always use the full, absolute path to both the PHP binary and the bin/magento file, rather than a relative path, or the job will fail silently.

Troubleshooting