In Magento, cron jobs are essential for automating various tasks and processes within the e-commerce platform. Cron is a time-based job scheduler in Unix-like operating systems, and Magento utilizes it to schedule and execute periodic tasks. Magento's cron jobs are responsible for performing critical operations like generating sales reports, sending transactional emails, updating product price rules, and performing database backups, among other scheduled tasks.
The Magento cron jobs are configured and managed through the crontab file, which specifies the schedule and commands to be executed. By properly configuring and monitoring the Magento cron jobs, administrators can ensure the timely and efficient execution of routine tasks, leading to a smooth operation of the e-commerce store and better overall performance.
When Magento reports cron jobs (or cronjobs) are not installed, the following steps can be used to recreate the default cron jobs or remove them if necessary. Useful if default cron jobs for Magento are not installed and Magento reports that they're not installed.
Install Default Jobs
- SSH into the server
- Navigate to the document root for the site with
cd public_html
REPLACE: public_html with the site's document root. - Install the cron jobs for Magento with
php bin/magento cron:install
- To clear the error, run the cron jobs immediately with
php bin/magento cron:run
EXAMPLE:
imhkmc5@imhkm.com [~]$ cd public_html
imhkmc5@imhkm.com [~/public_html]$ php bin/magento cron:install
Crontab has been generated and saved
imhkmc5@imhkm.com [~/public_html]$ php bin/magento cron:run
Ran jobs by schedule.
imhkmc5@imhkm.com [~/public_html]$
TIP: Check the cron tab by running crontab -l
to see the new entries.
EXAMPLE: The new entries should look similar to the following:
#~ MAGENTO START 670ecb1c57eb282ee060de0bbdbb4c3a
SHELL="/usr/local/cpanel/bin/jailshell"
* * * * * /opt/cpanel/ea-php71/root/usr/bin/php /home/USERNAME/public_html/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /home/USERNAME/public_html/var/log/magento.cron.log
SHELL="/usr/local/cpanel/bin/jailshell"
* * * * * /opt/cpanel/ea-php71/root/usr/bin/php /home/USERNAME/public_html/update/cron.php >> /home/USERNAME/public_html/testing/var/log/update.cron.log
SHELL="/usr/local/cpanel/bin/jailshell"
* * * * * /opt/cpanel/ea-php71/root/usr/bin/php /home/USERNAME/public_html/bin/magento setup:cron:run >> /home/USERNAME/public_html/var/log/setup.cron.log
#~ MAGENTO END 670ecb1c57eb282ee060de0bbdbb4c3
Remove the Jobs
- SSH into the server
- Navigate to the document root for the site with
cd public_html
REPLACE: public_html with the site's document root. - Remove any installed cron jobs with
php bin/magento cron:remove
TIP: This should remove all of the Magento cron tab entries installed with Magento CLI. To double-check, run crontab -l
to make sure and manually remove any remaining using cPanel's Cron Jobs interface or by running crontab -e
and deleting the relevant lines. Make sure to save the crontab file before or on exit.
Comments
0 comments
Article is closed for comments.