{"id":10752,"date":"2016-02-11T17:04:19","date_gmt":"2016-02-11T14:04:19","guid":{"rendered":"http:\/\/blog.belvg.com\/?p=10752"},"modified":"2019-03-27T10:56:08","modified_gmt":"2019-03-27T08:56:08","slug":"how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html","title":{"rendered":"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison"},"content":{"rendered":"<p>Before I tell you about the cron jobs in <b>Magento 2.0<\/b>, let me remind you how it can be enabled in Magento 1.x.<\/p>\n<p><!--more--><strong>Magento 1.x<\/strong><\/p>\n<p>First of all, you need to create a module (I hope that if you are reading this article, you remember how it can be done :) ). After that you need to add the module to the <b>config.xml<\/b> file.<\/p>\n<pre class=\"lang:php decode:true \">...\r\n&lt; crontab &gt; \r\n        &lt; jobs &gt; \r\n            &lt; belvg_cron &gt; \r\n                &lt; schedule &gt;&lt; cron_expr &gt; * * * * *&lt;\/ cron_expr &gt;&lt;\/ schedule &gt; \r\n                &lt; run &gt;&lt; model &gt; mymodule \/ cron:: myCronFunction&lt;\/ model &gt;&lt;\/ run &gt; \r\n            &lt;\/ belvg_cron&gt; \r\n        &lt;\/ jobs &gt; \r\n&lt;\/ crontab &gt;\r\n...<\/pre>\n<p>Next step is to create a file model:<\/p>\n<p><b>app\/code\/Belvg\/Mymodule\/Model\/Cron.php<\/b>.<\/p>\n<pre class=\"lang:php decode:true \">class Belvg_Mymodule_Model_Cron\r\n{\r\n    public function myCronFunction()\r\n    {\r\n        Mage::log(&#8216;Hello form Belvg&#8217;);\r\n        return $this;\r\n    }\r\n}<\/pre>\n<p>This task is triggered every minute and writes messages in the log.<\/p>\n<p>Now I will tell you how to enable cron jobs in <strong>Magento 2.0<\/strong>.<\/p>\n<p>How can you do it?<br \/>\nThis is also relatively easy and can be done in 2 steps:<\/p>\n<p>1. Create a file <strong>app\/code\/Belvg\/Mymodule\/etc\/crontab.xml <\/strong><\/p>\n<p><strong>app\/code\/Belvg\/Mymodule\/etc\/<\/strong> with the following content:<\/p>\n<pre class=\"lang:php decode:true \">&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Cron:etc\/crontab.xsd\"&gt;\r\n    &lt;group id=\"default\"&gt;\r\n        &lt;job name=\"belvg_mymodule_cron\" instance=\"Belvg\\Mymodule\\Model\\Cron\" method=\"myCronFunction\"&gt;\r\n            &lt;schedule&gt;* * * * *&lt;\/schedule&gt;\r\n        &lt;\/job&gt;\r\n    &lt;\/group&gt;\r\n&lt;\/config&gt;<\/pre>\n<p>2. Create a class <strong>app\/code\/Belvg\/Mymodule\/Model\/Cron.php<\/strong><\/p>\n<pre class=\"lang:php decode:true\">namespace Belvg\\Mymodule\\Model\r\n\r\nclass Cron \r\n{\r\n    protected $logger;\r\n\r\n    public function __constructor(\r\n        \\Psr\\Log\\LoggerInterface $logger\r\n        )\r\n    {\r\n        $this-&gt;logger = $logger;\r\n    }\r\n\r\n    public function myCronFunction()\r\n    {\r\n       $this-&gt;logger-&gt;info(&#8216;Hello form Belvg&#8217;);\r\n       return $this;\r\n    }\r\n}<\/pre>\n<p>That&#8217;s it.<\/p>\n<p>We created a cronjob in Magento 2. Now in logs: <strong>var\/log\/system.log<\/strong>, you can see the following message:<\/p>\n<p><em>[2016-01-14 08:00:00] main.INFO: Hello from Belvg<\/em><\/p>\n<p>Hope it will help to adapt your extensions for Magento 2.0.<\/p>\n","protected":false},"excerpt":{"rendered":"Before I tell you about the cron jobs in Magento 2.0, let me remind you &#8230;","protected":false},"author":50,"featured_media":10753,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,389],"tags":[],"class_list":["post-10752","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento","category-magento2-development","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Before I tell you about the cron jobs in Magento 2.X, let me remind you how it can be enabled in Magento 1.X.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Oleg Semenov\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#article\",\"name\":\"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison | BelVG Blog\",\"headline\":\"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/oleg-semenov#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/blog-mage1vs2.jpg\",\"width\":682,\"height\":170,\"caption\":\"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison\"},\"datePublished\":\"2016-02-11T17:04:19+02:00\",\"dateModified\":\"2019-03-27T10:56:08+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#webpage\"},\"articleSection\":\"Magento, Magento 2 Development, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"position\":2,\"name\":\"Magento\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#listItem\",\"name\":\"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#listItem\",\"position\":3,\"name\":\"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/oleg-semenov#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/oleg-semenov\",\"name\":\"Oleg Semenov\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/316f0b410659190b56484ecdb7a98dce16a901ebe753c233c0f407ba96e81b1a?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Oleg Semenov\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html\",\"name\":\"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison | BelVG Blog\",\"description\":\"Before I tell you about the cron jobs in Magento 2.X, let me remind you how it can be enabled in Magento 1.X.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/oleg-semenov#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/oleg-semenov#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/blog-mage1vs2.jpg\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html\\\/#mainImage\",\"width\":682,\"height\":170,\"caption\":\"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#mainImage\"},\"datePublished\":\"2016-02-11T17:04:19+02:00\",\"dateModified\":\"2019-03-27T10:56:08+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison | BelVG Blog","description":"Before I tell you about the cron jobs in Magento 2.X, let me remind you how it can be enabled in Magento 1.X.","canonical_url":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#article","name":"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison | BelVG Blog","headline":"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison","author":{"@id":"https:\/\/belvg.com\/blog\/author\/oleg-semenov#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2016\/02\/blog-mage1vs2.jpg","width":682,"height":170,"caption":"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison"},"datePublished":"2016-02-11T17:04:19+02:00","dateModified":"2019-03-27T10:56:08+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#webpage"},"articleSection":"Magento, Magento 2 Development, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","position":2,"name":"Magento","item":"https:\/\/belvg.com\/blog\/category\/magento","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#listItem","name":"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#listItem","position":3,"name":"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/oleg-semenov#author","url":"https:\/\/belvg.com\/blog\/author\/oleg-semenov","name":"Oleg Semenov","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/316f0b410659190b56484ecdb7a98dce16a901ebe753c233c0f407ba96e81b1a?s=96&d=mm&r=g","width":96,"height":96,"caption":"Oleg Semenov"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#webpage","url":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html","name":"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison | BelVG Blog","description":"Before I tell you about the cron jobs in Magento 2.X, let me remind you how it can be enabled in Magento 1.X.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/oleg-semenov#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/oleg-semenov#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2016\/02\/blog-mage1vs2.jpg","@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html\/#mainImage","width":682,"height":170,"caption":"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison"},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html#mainImage"},"datePublished":"2016-02-11T17:04:19+02:00","dateModified":"2019-03-27T10:56:08+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"10752","title":"How to set up cronjobs in Magento 1.x and Magento 2.0. Comparison | #site_title","description":"Before I tell you about the cron jobs in Magento 2.X, let me remind you how it can be enabled in Magento 1.X.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:33","updated":"2026-11-03 18:37:33"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento\" title=\"Magento\">Magento<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento","link":"https:\/\/belvg.com\/blog\/category\/magento"},{"label":"How to Set Up CronJobs in Magento 1.x and Magento 2.0. Comparison","link":"https:\/\/belvg.com\/blog\/how-to-set-up-cronjobs-in-magento-1-x-and-magento-2-0-comparison.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/10752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/50"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=10752"}],"version-history":[{"count":-3,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/10752\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/10753"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=10752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=10752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=10752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}