How to Setup Cron Job Magento 2 - Schedule Tasks
With a big catalog of 234+ extensions for your online store
Configure Cronjob in Magento 2 (Schedule Tasks) allows some operations run automatically on your Magento 2 site via a script you have written in the configuration. The operations you can control their scheduling from Magento Scheduler include:
The cron job is the awesome periodical method to make any of your important programs active automatically and properly instead of doing them manually. However, it is sure that the base URLs for the store are set correctly, so the URLs that are generated and used during cron operations are correct as well as the cron can be run perfectly.
Explore: Magento 2 Cron Schedule module
Thus, this tutorial will help know what you need to do to configure the cron. We are going to discuss two ways to set up a cron job: via Magento Admin, and using Command Line.
To setup Cron Job in Magento 2 admin:
In this way, you can configure cron jobs in the backend by logging into your admin account:
- On the Magento Admin, click
Stores
. In theSettings
section, selectConfiguration
. - Select
System
underAdvanced
in the panel on the left - Open the
Cron
section, and continue with following:
- Open
Cron configuration options for group: Index
andCron configuration options for group: Default
section and complete all following information
- Generate Schedules Every
- Schedule Ahead for
- Missed if not Run Within
- History Cleanup Every
- Success History Lifetime
- Failure History Lifetime
- Use Separate Process
- When cron job setup complete, click
Save Config
Setup Magento 2 Cron job by command line:.
To setup cron job for Magento 2, you should run the following command line to update the cronjob table:
crontab -e
Add the following lines to your crontab file:
*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento cron:run
*/1 * * * * php -c {php.ini_path} {magento_path}/update/cron.php
*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento setup:cron:run
In this case, our enviroment is that: {php.ini_path}
is /etc/php5/apache2/php.ini
; and {magento_path}
is /var/www/m2
, so the command cronjob is:
*/1 * * * * php -c /etc/php5/apache2/php.ini /var/www/m2/bin/magento cron:run
*/1 * * * * php -c /etc/php5/apache2/php.ini /var/www/m2/update/cron.php
*/1 * * * * php -c /etc/php5/apache2/php.ini /var/www/m2/bin/magento setup:cron:run
Save and close the crontab file.
Nano editor
: PressCtrl + O
to save thenCtrl + X
to quit.Vim editor
: PressEscape
,:wq
to save and quit.
The bottom line
Setting up Cron Job for Magento 2 is vital to schedule repetitive activities on your website. A smooth cron job can ensure good site performance and improve customer experience. I hope you have gained understanding on how to set up a cron job for your Magento 2 store via Magento Admin or Command Line. If you need further support, contact us here.
Explore Magento 2 Cron Schedule
Related topics
Looking for
Customization & Development Services?
8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.
Get free consultantRecent Tutorials
Change Store Email Addresses
Fix Magento 2 'Invalid Form Key. Please refresh the page'
Magento 2 Search Settings: Default Magento vs Mageplaza AJAX Search
Explore Our Products:
People also searched for
- how to setup cron job in magento 2 admin
- magento 2 cron configuration admin
- how to setup cron job in magento 2
- magento 2 cron scheduler
- check cron scripts magento 2
- magento 2 cron configuration
- magento 2 enable cron jobs
- magento cron job setup
- magento 2 cron setup
- magento 2 disable cron job
- magento 2 cron job cpanel
- magento 2 configure cron
- magento 2 cron settings
- magento cron setup
- magento cron settings
- disable cron magento 2
- magento 2 cron job for indexing
- magento 2 cron job is missed
- how to setup cron job in magento admin
- magento cron jobs
- magento setup cron
- aoe_scheduler magento 2
- how to set cron job in magento 2
- magento cronjob
- magento cron job
- how to setup the magento cron
- magento 2 add cron job
- magento 2 stop all cron jobs
- how to set up cron job in magento
- how to setup magento cron
- magento disable cron
- 2.2.x, 2.3.x, 2.4.x
Stay in the know
Get special offers on the latest news from Mageplaza.
Earn $10 in reward now!