There are a lot of Mage options that require at minimum one cron job. Magento Cron job’s schedule operations to take place in future. Here is the list of activities require Mage Corn jobs.
- To setup the price rules for each catalogue.
- Secondly Press release & Newsletters.
- Thirdly producing Google sitemaps.
- Jobs like site notifications and client alert notifications.
- For example: changes made on price, sell, discount etc.
- Site Re indexing after editing page or content.
- Also for Personal sales (only for Magento EE clients)
- Updating currency conversation rates regularly.
- Finally, Mage e-mails both for transection and order confirmation etc.
It I recommended to use Mage corn as File Sys Admin. Hence you can also run Mage corn as web server admin. However, if you’re running Mage corn as root should be avoided.
Magento Cron configuration using cPanel
Particularly for setting up a new Mage cron job via cPanel follow these steps.
Then Login to your cPanel by using user id and password. Please contact with your hosting provider for more details on cP.
http://mydomain.com:2082/
or
https://mydomian.com:2083/
Next, type in cron in search box and press enter. As a result you’ll find a Mage Cron job options under the Advanced options in cP.
Furthermore, for setting up Mage cron using cPanel, you’ll need a valid email address. Type in the email address under the Cron email box. Then press enter to submit that email. The email will be utilized to send messages from Mage cron. Undoubtedly it is a useful feature. As you will be updated on regular basis using this email about your cron execution status.
Hereafter setup the Mage cron schedule. Now enter the value as command to run cron jobs successfully. Finally click “Add New Cron Job” to finalize your setup.
New Magento cron task using SSH
Firstly, log in to your server using SSH. Hereafter to add a cron job run -e command in crontab. Next a text editor will appear shortly. Here you can edit previous cron jobs or can add new tasks. Type in the following code by starting a new line.
*/5 * * * * sh /path/to/your/magento/site/root/cron.sh
Use your own default path to do it correctly!
Finally, to finish off close the and save the changes. In cron tab -I command will appear with new task created if everything has done in correct format.
Note:
Cron commands in different Magento versions
Remember, the “run cron job” commands are separate for different Mage versions.
Mage Cron commands for Magento 1.x & 2.x are described below.
sh /path/to/your/magento/site/root/cron.sh
For Magento 2.x
php /path/to/your/magento/site/root/bin/magento — –quiet cron:run
Again, remember to change the path of your Mage website as required to setup cron jobs correctly. Hence, Mage 1.x has the privilage to process cron jobs using the site URL. However, it is not recommend to do so. These methods produce errors due to multitasking. Specifically, parallel cron jobs make it worse. It can lead to server issues that results in job processing erros.
***The common mistakes***
How to make sure the valid instructions?
According to expert coders, these are the common mistakes made while setting Mage cron jobs up. Firstly, try to not copy any commands from the Internet. Hence, it is often that most instructions are perfect. But these codes need to be updated with time as your servers do. Or they were proper when written but have not been further updated.
In depth:
We will always refer to your hosting support articles and system admin about correct commands. Mostly they will always update codes from authentic Mage doc sources.
Suppose, any other article published on XYZ site put the commands like following.
*/5 * * * * /var/www/magento/cron.sh
Undoubtedly the instruction is correct. But you need to take consideration on the permissions also. At this instance “/var/www/magento/cron.sh” the file should also run the execution. Following is an worldwide method to permit the command executer to run the file.
*/5 * * * * sh /var/www/magento/cron.sh
Just another case to study for Magento cron jobs
This is another example of commands randomly taken from a website.
*/5 * * * * /usr/bin/php /var/www/magento/cron.php
In such case sometimes the command will not work for you. If your PHP is under another file or folder for example: or /opt/php/bin/php the command will fail to execute. As a result, it always better to use a cron.sh instead of cron.php. The cron.sh itself searches PHP interpreter automatically.
Furthermore visit Mage Official for more info on Cron jobs.
Aspiration hosting comes with Full web development and 24×7 customer support. If you’re having trouble with development such as how to set up cron jobs. No worries! Our technical experts will lead you to the ultimate solution. In conclusion, our cPanel is now more powerful than ever to create your cron jobs using our cPanel Apps. Plan begin at $9.99 per month.
Tanzia Farin Chowdhury for Aspiration Hosting