{"id":2542,"date":"2011-09-29T10:10:21","date_gmt":"2011-09-29T14:10:21","guid":{"rendered":"https:\/\/webhostinggeeks.com\/blog\/?p=2542"},"modified":"2012-04-12T10:37:12","modified_gmt":"2012-04-12T14:37:12","slug":"cpanel-setup-cron-jobs","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/blog\/cpanel-setup-cron-jobs\/","title":{"rendered":"Using cPanel to Setup Cron Jobs"},"content":{"rendered":"<p>The &#8220;cron job&#8221; is one of the basic programming tools that remind you that you can get a lot of function out of learning just a little code.\u00a0 A &#8220;cron job&#8221; is simply a command that you instruct your server to perform at regular intervals.\u00a0 It can literally be any command that you can run normally.<!--more--><\/p>\n<p><strong>You have the power!<\/strong><\/p>\n<p>Not only are the advantages of this obvious, but once you realize the power you can get from this in just a few commands, much of what you use control panels for may start to seem frivolous.\u00a0 You can, for example, in just a single command backup an entire directory once a week and email it to yourself.\u00a0 Don&#8217;t be scared: we are diving a bit into expert stuff here, but only to prove the point.\u00a0 You can do a lot with very little.<\/p>\n<p><strong>So how do you do it?<\/strong><\/p>\n<p><iframe width=\"660\" height=\"315\" data-src=\"http:\/\/www.youtube.com\/embed\/TBr47SVcymI\" frameborder=\"0\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<p>Even by cPanel standards this is one of the easier functions to perform.\u00a0Scroll down in your cPanel home page.\u00a0 You&#8217;ll probably find &#8220;Cron Jobs&#8221; in the Advanced section.\u00a0Click on it and you&#8217;ll be asked whether you like it easy or hard.\u00a0 Personal preferences aside, there&#8217;s not much reason to go hard.\u00a0Click on \u201cStandard\u201d to get to the main cron jobs screen.<\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/blog\/wp-content\/uploads\/2011\/09\/cron-jobs-in-cpanel.jpg\" alt=\"cron jobs cpanel\" title=\"cron jobs cpanel\" width=\"519\" height=\"191\" class=\"alignnone size-full wp-image-4241 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/blog\/wp-content\/uploads\/2011\/09\/cron-jobs-in-cpanel.jpg 519w, https:\/\/webhostinggeeks.com\/blog\/wp-content\/uploads\/2011\/09\/cron-jobs-in-cpanel-128x47.jpg 128w, https:\/\/webhostinggeeks.com\/blog\/wp-content\/uploads\/2011\/09\/cron-jobs-in-cpanel-420x155.jpg 420w, https:\/\/webhostinggeeks.com\/blog\/wp-content\/uploads\/2011\/09\/cron-jobs-in-cpanel-372x137.jpg 372w, https:\/\/webhostinggeeks.com\/blog\/wp-content\/uploads\/2011\/09\/cron-jobs-in-cpanel-328x121.jpg 328w\" data-sizes=\"(max-width: 519px) 100vw, 519px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 519px; --smush-placeholder-aspect-ratio: 519\/191;\" \/><\/p>\n<p>You will first enter the email address that the results of the cron job will be sent: if it is not successful, the email will contain the error message, though this may require some debugging on your part.\u00a0 Next you will enter the command.\u00a0 One unavoidable technical note: the command must be typed in using the full path.\u00a0 So if you are running a script that is in your home directory, you must specify the full server path to it.<\/p>\n<p><strong>Get your timing right<\/strong><\/p>\n<p>Now you need to specify how often you want the cron job to run.\u00a0 Most of this is self-explanatory, though there is at least one potentially confusing item.\u00a0 You can specify the days that the job will run both by days of the month and days of the week.\u00a0 That&#8217;s not confusing by itself, but what happens if you choose both?\u00a0 Let&#8217;s look at the combinations.<\/p>\n<ul>\n<li><strong>&#8220;Days&#8221; = &#8220;Every Day&#8221; <\/strong>and<strong> &#8220;Week Days&#8221; = &#8220;Every Week Day&#8221;:<\/strong> This will run the cron job on every single day.<\/li>\n<li><strong>&#8220;Days&#8221; = &#8220;2&#8221; <\/strong>and <strong>&#8220;Week Days&#8221; = &#8220;Every Week Day&#8221;<\/strong>: This will run the job on the 2<sup>nd<\/sup> day of the month only.<\/li>\n<li><strong>&#8220;Days&#8221; = &#8220;Every Day&#8221;<\/strong> and <strong>&#8220;Week Days&#8221; = &#8220;Tuesday&#8221;<\/strong>: This will run the job on every Tuesday.<\/li>\n<li><strong>&#8220;Days&#8221; = &#8220;2&#8221; and &#8220;Week Days&#8221; = &#8220;Tuesday&#8221;<\/strong>: This will run the job on the 2<sup>nd<\/sup> Tuesday of the month only.<\/li>\n<\/ul>\n<p><strong>That&#8217;s it!<\/strong><\/p>\n<p>Now hit &#8220;Save Crontab&#8221; and you&#8217;re done!\u00a0 You can then go back to this later and delete or modify the job.\u00a0 Note that you can also create mulitple cron jobs, even if they use the same commands.\u00a0 You might want to, say, backup a certain directory every day, and your entire account every month.<\/p>\n<p>Now the only thing you need to do is learn the commands you want to run.\u00a0 This should make clear that this is worth the effort.\u00a0 Cron jobs are one of the most useful basic tools for just about any developer, and cPanel makes using them even easier.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The &#8220;cron job&#8221; is one of the basic programming tools that remind you that you can get a lot of function out of learning just a little code.\u00a0 A &#8220;cron&#8230;<\/p>\n","protected":false},"author":58,"featured_media":4240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[8],"tags":[19,20,2185,2000,2995,7194],"class_list":["post-2542","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-control-panels","tag-control-panel","tag-cpanel","tag-cron-job","tag-cron-jobs","tag-mulitple-cron-jobs","tag-programming"],"views":99,"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/posts\/2542","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/users\/58"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/comments?post=2542"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/posts\/2542\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/media\/4240"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/media?parent=2542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/categories?post=2542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/blog\/wp-json\/wp\/v2\/tags?post=2542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}