{"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 class=\"wp-block-paragraph\">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 class=\"wp-block-heading\" id=\"configuring-cron-job-via-the-command-line\">Step 1. Connect to Magento server using SSH<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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 class=\"wp-block-heading\">Step 2. Find the PHP binary and php.ini path<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once you&#8217;ve connected to the Magento server &#8211; find the PHP binary and php.ini path<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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\" data-line=\"\">which php<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" 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 class=\"wp-block-paragraph\">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\" data-line=\"\">\/usr\/bin\/php<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" 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 class=\"wp-block-heading\">Step 3. Open the cron tab editor<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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\" data-line=\"\">crontab -e<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" 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 class=\"wp-block-paragraph\">After this command has been performed &#8211; the cron tab editor will open.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" 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 class=\"wp-block-heading\">Step 4. Copy the code to set up a cron job<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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\" data-line=\"\">* * * * * &lt;path to php binary&gt; &lt;magento install dir&gt;\/bin\/magento cron:run | grep -v &quot;Ran jobs by schedule&quot; &gt;&gt; &lt;magento install dir&gt;\/var\/log\/magento.cron.log\n* * * * * &lt;path to php binary&gt; &lt;magento install dir&gt;\/update\/cron.php &gt;&gt; &lt;magento install dir&gt;\/var\/log\/update.cron.log\n* * * * * &lt;path to php binary&gt; &lt;magento install dir&gt;\/bin\/magento setup:cron:run &gt;&gt; &lt;magento install dir&gt;\/var\/log\/setup.cron.log<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">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 decoding=\"async\" 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 class=\"wp-block-paragraph\">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":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[126],"tags":[131,132],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-magento-setup","tag-magento-cron-job","tag-magento-setup","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\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 name=\"author\" content=\"Anastasiia Yaremchuk\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anastasiia Yaremchuk\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set Up a Cron Job in Magento 2 - Magento Tutorials for Beginners &amp; Professionals","description":"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.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job","og_locale":"en_US","og_type":"article","og_title":"How to Set Up a Cron Job in Magento 2 - Magento Tutorials for Beginners &amp; Professionals","og_description":"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.","og_url":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job","og_site_name":"Magento Tutorials for Beginners &amp; Professionals","article_published_time":"2021-07-01T14:27:58+00:00","article_modified_time":"2022-10-06T08:40:59+00:00","author":"Anastasiia Yaremchuk","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Anastasiia Yaremchuk","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job#article","isPartOf":{"@id":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job"},"author":{"name":"Anastasiia Yaremchuk","@id":"https:\/\/plumrocket.com\/learn\/#\/schema\/person\/e58760eb45dab7b988fbd2ae2fc84e9c"},"headline":"How to Set Up a Cron Job in Magento 2","datePublished":"2021-07-01T14:27:58+00:00","dateModified":"2022-10-06T08:40:59+00:00","mainEntityOfPage":{"@id":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job"},"wordCount":213,"commentCount":0,"keywords":["magento cron job","magento setup"],"articleSection":["Magento Setup"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/plumrocket.com\/learn\/magento-setup-cron-job#respond"]}]},{"@type":"WebPage","@id":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job","url":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job","name":"How to Set Up a Cron Job in Magento 2 - Magento Tutorials for Beginners &amp; Professionals","isPartOf":{"@id":"https:\/\/plumrocket.com\/learn\/#website"},"datePublished":"2021-07-01T14:27:58+00:00","dateModified":"2022-10-06T08:40:59+00:00","author":{"@id":"https:\/\/plumrocket.com\/learn\/#\/schema\/person\/e58760eb45dab7b988fbd2ae2fc84e9c"},"description":"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.","breadcrumb":{"@id":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/plumrocket.com\/learn\/magento-setup-cron-job"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/plumrocket.com\/learn\/magento-setup-cron-job#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Learn","item":"https:\/\/plumrocket.com\/learn"},{"@type":"ListItem","position":2,"name":"How to Set Up a Cron Job in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/plumrocket.com\/learn\/#website","url":"https:\/\/plumrocket.com\/learn\/","name":"Magento Tutorials for Beginners &amp; Professionals","description":"Plumrocket Inc","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/plumrocket.com\/learn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/plumrocket.com\/learn\/#\/schema\/person\/e58760eb45dab7b988fbd2ae2fc84e9c","name":"Anastasiia Yaremchuk","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/plumrocket.com\/learn\/wp-content\/uploads\/2024\/01\/avatar_user_3_1704905220-96x96.png","url":"https:\/\/plumrocket.com\/learn\/wp-content\/uploads\/2024\/01\/avatar_user_3_1704905220-96x96.png","contentUrl":"https:\/\/plumrocket.com\/learn\/wp-content\/uploads\/2024\/01\/avatar_user_3_1704905220-96x96.png","caption":"Anastasiia Yaremchuk"},"description":"Deeply passionate about making a good copy. Now exploring new horizons of SEO and content marketing. Apart from the digital world, she is obsessed with travelling, films and caffeine.","url":"https:\/\/plumrocket.com\/learn\/author\/anastasiia-tomashivska"}]}},"_links":{"self":[{"href":"https:\/\/plumrocket.com\/learn\/wp-json\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"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}]}}