Reading list Switch to dark mode

    How To Setup CRON For Magento 2

    Updated 16 February 2024

    In this post, we will learn to set up cron on the server for Magento 2 cron. In Magento 2 development there are many configurations that need cron for the proper working of your Magento.

    Some of the tasks which are handled by cron in Magento 2 are:

    • Catalog price rules
    • Newsletters
    • Generating Google Sitemaps
    • Customer Alerts/Notifications
    • Reindexing
    • Automatic updating of currency rates

    Now we will be going to set up cron on the server.

    Run the following command from the terminal

    crontab -e

    If you are logged in as root user you can specify the cronjob for the Magento file system owner only by specifying the username by using the -u switch.

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    crontab -u <magento file system user> -e

    When you hit the above command, editor option will appear select anyone in which you are comfortable with. In the editor enter the following cronjob.

    * * * * * <path to php binary> <magento install dir>/bin/magento cron:run

    In my case I have used the following command.

    * * * * * php /home/ayaz/www/html/mage2/bin/magento cron:run

    We are done with the setup for the server. Please note that the cronjob I set up is running every minute. You can schedule it as per your need. You can check the cron has setup correctly by viewing the cron_schedule table in your Magento database. You will see entries like this:


    You can learn more on cron in this post:

    That’s all for cron setup on server for magento, you can query or give feedback in the comments below, it will help us in improving. Hope this post will help you. Thanks ­čÖé

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home