{"id":383,"date":"2021-07-01T17:27:58","date_gmt":"2021-07-01T14:27:58","guid":{"rendered":"http:\/\/wp.plumserver.com\/learn\/?p=383"},"modified":"2022-10-06T11:40:59","modified_gmt":"2022-10-06T08:40:59","slug":"how-to-setup-a-cron-job-in-magento-2","status":"publish","type":"post","link":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job","title":{"rendered":"How to Set Up a Cron Job in Magento 2"},"content":{"rendered":"\n<p>In this article, you will learn how to set up a cron job in Magento 2 via the Command Line. Setting the cron jobs is an essential part to ensure the proper functioning of your Magento 2 store.<\/p>\n\n\n\n<h2 id=\"configuring-cron-job-via-the-command-line\">Step 1. Connect to Magento server using SSH<\/h2>\n\n\n\n<p>Connect to the Magento server using SSH. Read details for <a href=\"https:\/\/mediatemple.net\/community\/products\/dv\/204404604\/using-ssh-in-putty-\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">Windows OS<\/a> or <a href=\"https:\/\/mediatemple.net\/community\/products\/dv\/204405144\/using-ssh-in-terminal.app-(mac-os-x)\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">MAC OS or Linux OS<\/a><\/p>\n\n\n\n<h2>Step 2. Find the PHP binary and php.ini path<\/h2>\n\n\n\n<p>Once you&#8217;ve connected to the Magento server &#8211; find the PHP binary and php.ini path<\/p>\n\n\n\n<p>To discover the path to your PHP binary, please type the following command:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\"><\/div><pre><code class=\"language-bash\">which php<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"\/learn\/wp-content\/uploads\/2020\/05\/Magento_2_cron_job_setup_1.png\" alt=\"Magento 2 cron job setup 1\"\/><\/figure>\n\n\n\n<p>A sample result will be as the following:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\"><\/div><pre><code class=\"language-bash\">\/usr\/bin\/php<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"\/learn\/wp-content\/uploads\/2020\/05\/Magento_2_cron_job_setup_2.png\" alt=\"Magento 2 cron job setup 2\"\/><\/figure>\n\n\n\n<h2>Step 3. Open the cron tab editor<\/h2>\n\n\n\n<p>Execute the following command in order to edit the cron tab.<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\"><\/div><pre><code class=\"language-bash\">crontab -e<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"\/learn\/wp-content\/uploads\/2020\/05\/Magento_2_cron_job_setup_3.png\" alt=\"Magento 2 cron job setup 3\"\/><\/figure>\n\n\n\n<p>After this command has been performed &#8211; the cron tab editor will open.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"\/learn\/wp-content\/uploads\/2020\/05\/Magento_2_cron_job_setup_4.png\" alt=\"Magento 2 cron job setup 4\"\/><\/figure>\n\n\n\n<h2>Step 4. Copy the code to set up a cron job<\/h2>\n\n\n\n<p>To set up the cron jobs, paste the following lines of code:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div class=\"prism-title\"><\/div><pre><code class=\"language-markup\">* * * * * &lt;path to php binary> &lt;magento install dir>\/bin\/magento cron:run | grep -v \"Ran jobs by schedule\" >> &lt;magento install dir>\/var\/log\/magento.cron.log\n* * * * * &lt;path to php binary> &lt;magento install dir>\/update\/cron.php >> &lt;magento install dir>\/var\/log\/update.cron.log\n* * * * * &lt;path to php binary> &lt;magento install dir>\/bin\/magento setup:cron:run >> &lt;magento install dir>\/var\/log\/setup.cron.log<\/code><\/pre><\/div>\n\n\n\n<p>where <strong>&lt;path to php binary&gt;<\/strong> is the absolute file system path to your PHP binary, and <strong>&lt;magento install dir&gt;<\/strong> is your Magento root folder. For example, \/var\/www\/mystore<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"\/learn\/wp-content\/uploads\/2020\/05\/Magento_2_cron_job_setup_5.png\" alt=\"Magento 2 cron job setup 5\"\/><\/figure>\n\n\n\n<p>This way your Magento 2 cron jobs should be up and running.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article you will learn how to setup a cron job in Magento 2. Setting the cron jobs is an essential part to ensure the proper functioning of your Magento 2 store.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[126],"tags":[131,132],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Set Up a Cron Job in Magento 2 - Magento Tutorials for Beginners &amp; Professionals<\/title>\n<meta name=\"description\" content=\"Learn how to set up a cron job in Magento 2, which is an essential part to ensure the proper functioning of your Magento 2 store.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Up a Cron Job in Magento 2 - Magento Tutorials for Beginners &amp; Professionals\" \/>\n<meta property=\"og:description\" content=\"Learn how to set up a cron job in Magento 2, which is an essential part to ensure the proper functioning of your Magento 2 store.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job\" \/>\n<meta property=\"og:site_name\" content=\"Magento Tutorials for Beginners &amp; Professionals\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-01T14:27:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-06T08:40:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/plumrocket.com\/learn\/wp-content\/uploads\/2020\/05\/Magento_2_cron_job_setup_1.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/383"}],"collection":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":9,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":1228,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/383\/revisions\/1228"}],"wp:attachment":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}