You are here
Home > All > Magento 2 Cron configuration

Magento 2 Cron configuration

A cron is a job scheduler on a UNIX operating system. It’s time-based. Thus, it can enable you to schedule shell scripts or commands to run in a certain period or time. It’s usually used in automating system administration or maintenance.

Cron Job in Magento

Cron jobs have to be enabled in order for Magento to work properly. With cron job, you no longer need to refresh your Magento catalog index every few minutes.

Magento cron job allows the following features to work in schedule:

  1. Sending newletters
  2. Cataloging price rules
  3. Generating Google Sitemaps
  4. Sending customer alerts or  notifications
  5. Updating currency rates
  6. Scheduling DB logs cleanup
  7. Reindexing
  8. Managing Magento e-mails
  9. Organizing private sales

Failure to set up Magento properly will cause these features to malfunction or not function at all.

Checking Cron Using Test Sweet

Sweet Tooth is built with diagnostic tools that allow you to know whether your Magento Cron is already set up properly. You only have to run this tool.

Navigate Rewards > Configuration > Other Configuration. Then, scroll down until you see Diagnostics and Support Tools. Click Run ‘Test Sweet’ Diagnostics. After doing so, you’ll see many lines of diagnostics. Scroll down to Magento Cron.

If the Cron has already been set up and running properly, it’ll look like this:

However, if it’s not, you will be shown a warning:

If you see this, you have to set up Magento Cron yourself.

Running Time for Magento Cron

Set up the Magento with the use of and run it every 5 minutes. You might have seen other recommendations, like running cron once in an hour or once in a minute. However, 5 minutes is the recommended time of Magento. If you use SSH, the command responsible for the schedule must be written like this: */5****

It is important to remember that the PHP configuration must be the same as the executions based on php binary. If not, some commands will not work.

Setting Magento Cron Job in UNIX

When you are running a UNIX operating system, it will automatically recognize requests from Magento to use the cron tab service.

The cron.php file sits inside the directory of Magento. Use this to manage and dispatch cron jobs. The cron.php script will execute the internal Magento cron job manager, sending commands when the cron jobs are to be executed.

It has to look like this:

Setting Magento Cron Job using cPanel

If you don’t see the cron tab, you can add it using the cPanel. Make sure that you have not yet set up another cron job calling cron.php file in Magento. Otherwise, it will not work.

Login to the control panel and find the Advance panel. Click the Cron Jobs icon and type the following details:

  1. Minutes
  2. Hour
  3. Day
  4. Month
  5. Weekday
  6. Command

For the minutes, remember that it should be */5. For the command, replace [magento_path] with your root directory in Magento installation URL.

Finally, click Add New Cron Job to insert it in the system.

Running Cron job in Web Browser

To run cron using your web browser, you need to secure cron.php in a browser first. Then, login to the Magento server. Using bash shell, you can use the syntax below:

To run Magento commands in any directory, add it to your system PATH by using this code: <your Magento intall directory>/bin and run them as ./magento <command name>.

Troubleshooting Magento Cron Job

If your cronjob is not working, you need to recheck its setup. Make sure that the instructions are valid. If you merely copy commands set in this tutorial, then it won’t work. Adapt the commands according to your server.

Also check your e-mail address. Make sure that you use the correct in the MAILTO. Why? Because you usually receive a message if something is not working well with the cron task execution.

Lastly, keep an eye on output redirection. If you receive a command like this:


Make sure that you address them directly.

Final Thoughts

Configuring Magento Cron Job is pretty easy. However, you might experience trouble in the first few tries. If you do, just try to check the commands. If you don’t know what the problem is, don’t hesitate to ask for help.

Magelancer is an enthusiast keen on the eCommerce ecosphere and advanced marketing strategies. With more than 7 years of tech blogging experience, Magelancer gets down to bed-rock and strives for sharing valuable content.

Similar Articles

Leave a Reply