The customer portal my.neoserv.com has been redesigned. If you notice any issues, please let us know.

Cart (0)
  • Your cart is currently empty.

USER INSTRUCTIONS

Search instructions

Cron jobs are used to execute predefined tasks on the server. These are executed automatically, either at a specific time, date or at defined intervals. You can read more about what cron jobs are, how they work and how to set them up in cPanel in the Cron Jobs article.

Cron jobs also play an important role in Magento. They are responsible for predefined activities related to page indexing and caching, sending emails, generating a sitemap, various updates, etc.

Check below how to set up cron jobs correctly in Magento 1.X and 2.X.

Command to execute a cron job

Magento 1.X

sh /home/user/public_html/cron.sh

Magento 2.X

php /home/user/public_html/bin/magento -- --quiet cron:run

For the above command, replace user with your actual username. If your Magento webshop installation is not located directly in the public_html folder, adjust the path accordingly. For owners of a medium-sized Magento store, we advise running the cron job every 5 minutes.

Setting up a cron job in the cPanel dashboard

The procedure for setting up cron jobs via the cPanel control panel is very simple:

1. log in to the cPanel Control Panel (cPanel login instructions).

2. Locate the Advanced icon group and click on the Cron Jobs icon.

cPanel (Jupiter) - Cron Jobs

3. If you are going to edit cron jobs in this way, you will need to enter an email address under Cron Email to receive any notifications about (un)successful activities.

Cron Email

4. Now it’s time to specify the frequency of the cron job. The following figure shows an example for Magento 1.X, where the job is executed every 5 minutes.

Adding a Cron Job

Make sure that you have specified the correct frequency for the job to run and that you have entered the correct path to the cron.sh file in the Command line. In case you have Magento 2.X installed, adjust the whole command.

5. All you have to do is click on the blue Add New Cron Job button.

Common errors when setting up cron jobs

The most common problem with running cron jobs is that the user copies a command from a guide he found somewhere on the web. Although the instructions are usually written correctly, minor adjustments are often necessary as not all servers have identical settings.

It is also possible that a command was written correctly at the time the guide was written, but due to software updates on the servers, another one has to be used.

Example:

*/5 * * * * * * /var/www/magento/cron.sh

The command is correct, but the permissions on the /var/www/magento/cron.sh file must allow it to be executed. You can use the universal way, which is to leave the execution of the file to the command executor:

*/5 * * * * * * sh /var/www/magento/cron.sh

Another common error is to redirect the output to /dev/null. This is used in case Magento has errors that are reported when executing cron jobs, but the user has no intention of removing them, so he prefers to hide them. The command looks like this:

*/5 * * * * * sh /var/www/magento/cron.sh >/dev/null 2>&1

This can be a problem, as important errors may occur during the execution of cron jobs, but the user will not be informed about them. This makes the process of detecting and resolving the error very difficult.

For further assistance, please call us on 059 335 000 or email us at info@neoserv.si.

COMMENTS

COMMENT THE POST

(mandatory)
(mandatory, email address will be hidden)
(optional)
Security question that confirms you are a real person.