{"id":193,"date":"2019-12-23T11:25:39","date_gmt":"2019-12-23T10:25:39","guid":{"rendered":"https:\/\/www.combell.com\/en\/help\/?post_type=ht_kb&#038;p=193"},"modified":"2024-09-16T16:36:41","modified_gmt":"2024-09-16T14:36:41","slug":"programming-recurring-tasks-with-cronjobs","status":"publish","type":"ht_kb","link":"https:\/\/www.combell.com\/en\/help\/kb\/programming-recurring-tasks-with-cronjobs\/","title":{"rendered":"Programming recurring tasks with Cronjobs"},"content":{"rendered":"\n<p><span style=\"vertical-align: inherit;\">A cronjob is the right way to program a recurring task that is executed by a script on your account.<\/span><\/p>\n\n\n\n<div class=\"wp-block-ht-block-toc  is-style-outline htoc htoc--position-wide toc-list-style-plain\" data-htoc-state=\"expanded\"><span class=\"htoc__title\"><span class=\"ht_toc_title\">Table of Contents<\/span><span class=\"htoc__toggle\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"16\" height=\"16\"><g fill=\"#444\"><path d=\"M15 7H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><path d=\"M15 1H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1zM15 13H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><\/g><\/svg><\/span><\/span><div class=\"htoc__itemswrap\"><ul class=\"ht_toc_list\"><li class=\"\"><a href=\"#controlpanel\">Add cronjobs via the control panel<\/a><\/li><li class=\"\"><a href=\"#ssh\">Add cronjobs via SSH<\/a><\/li><\/ul><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"controlpanel\"><span style=\"vertical-align: inherit;\">Add cronjobs via the control panel<\/span><\/h2>\n\n\n\n<p><strong><span style=\"vertical-align: inherit;\">Follow these steps <\/span><\/strong><strong><span style=\"vertical-align: inherit;\">in the <\/span><\/strong><a href=\"https:\/\/my.combell.com\/en\" target=\"_blank\" rel=\"noopener\"><span style=\"vertical-align: inherit;\">control panel<\/span><\/a><strong><span style=\"vertical-align: inherit;\">:<\/span><\/strong><\/p>\n\n\n\n<ol>\n<li><span style=\"vertical-align: inherit;\">Go to \u201cMy products\u201d> \u201cWeb hosting\u201d> Click on the button \u201cManage hosting\u201d to the right of your domain name.<\/span><\/li>\n\n\n\n<li><span style=\"vertical-align: inherit;\">Select &#8220;Developer tools&#8221; in the menu on the left<\/span> and click on &#8220;<span style=\"vertical-align: inherit;\">Scheduled Tasks\u201d.<\/span><\/li>\n\n\n\n<li>On the right, click on &#8220;Add&#8221;.<\/li>\n\n\n\n<li><span style=\"vertical-align: inherit;\">Choose the domain name and add the path to which the script was uploaded. <\/span><\/li>\n\n\n\n<li><span style=\"vertical-align: inherit;\">Select the desired frequency for your cron job (see image).<\/span><\/li>\n\n\n\n<li>Click on &#8220;Add cron job&#8221;<\/li>\n\n\n\n<li><span style=\"vertical-align: inherit;\">Add the script with the cronjob to your hosting environment.<\/span><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.combell.com\/en\/help\/wp-content\/uploads\/Screenshot-2024-09-16-at-16.35.26-1024x495.png\" alt=\"\" class=\"wp-image-24213\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ssh\"><span style=\"vertical-align: inherit;\">Add cronjobs via SSH<\/span><\/h2>\n\n\n\n<p><span style=\"vertical-align: inherit;\">The advantage of a cronjob set via SSH is that it can run for about twenty minutes before the server will stop the script, compared to only five minutes if the cronjob was set via the hosting control panel.<\/span><\/p>\n\n\n\n<p><span style=\"vertical-align: inherit;\">To add a cronjob via SSH you must first <\/span><a href=\"https:\/\/www.combell.com\/en\/help\/kb\/activate-ssh-on-your-hosting-package\/\"><span style=\"vertical-align: inherit;\">activate SSH<\/span><\/a><span style=\"vertical-align: inherit;\">. Then you have to edit the\/etc\/crontab file. We explain how you do that.<\/span><\/p>\n\n\n\n<p><strong><span style=\"vertical-align: inherit;\">Follow these steps to add a cronjob via SSH:<\/span><\/strong><\/p>\n\n\n\n<ol>\n<li><span style=\"vertical-align: inherit;\">Open your Terminal app or your Command Prompt (Command Line).<\/span><\/li>\n\n\n\n<li><span style=\"vertical-align: inherit;\">Enter the following command:<\/span><br><pre><span style=\"vertical-align: inherit;\">nano \/ etc \/ crontab<\/span><\/pre><br><\/li>\n\n\n\n<li><span style=\"vertical-align: inherit;\">Add your own cronjob. Check the correctness of the cronjob syntax (see example).<\/span><\/li>\n\n\n\n<li><span style=\"vertical-align: inherit;\">Save it by clicking on &#8220;CTRL&#8221; + &#8220;O&#8221;. Click &#8220;Enter&#8221; to confirm. Close with &#8220;CTRL&#8221; + &#8220;X&#8221;.<\/span><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.combell.com\/en\/help\/wp-content\/uploads\/2019\/11\/568aa1ffe3dc005303cc44a4.png\" alt=\"Add your own cronjob\" class=\"wp-image-6777\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>A cronjob is the right way to program a recurring task that is executed by a script on your account. Add cronjobs via the control panel Follow these steps in the control panel: Add cronjobs via SSH The advantage of a cronjob set via SSH is that it can run&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[20,4],"ht-kb-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/193"}],"collection":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":17,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/193\/revisions"}],"predecessor-version":[{"id":4388,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/193\/revisions\/4388"}],"wp:attachment":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb-category?post=193"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb-tag?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}