{"id":686,"date":"2024-06-18T14:04:02","date_gmt":"2024-06-18T14:04:02","guid":{"rendered":"https:\/\/zalvis.com\/docs\/?p=686"},"modified":"2024-06-18T14:04:02","modified_gmt":"2024-06-18T14:04:02","slug":"understanding-cron-jobs","status":"publish","type":"post","link":"https:\/\/zalvis.com\/docs\/understanding-cron-jobs.html","title":{"rendered":"Understanding Cron Jobs"},"content":{"rendered":"<p>When running a complex website, it makes sense to have a way of automating regular tasks, and never have to remind yourself to do them. This is what Cron Jobs is for \u2013 Linux commands that schedule things. That means, it is armed with a good knowledge of Linux commands, and you can make the best use of these Cron Jobs.<\/p>\n<p>A Cron Job can be quite handy, as it can be instructed to run in hourly or minutely increments, on a certain day every week or date every month &#8211; you can even mix and match these. Be advised, though, that running too many Cron Jobs too often can lead to undue stress on the servers. However, such limits may not be applicable to non-shared resources like a dedicated server.<\/p>\n<p>These Cron Jobs can be used for good old storage housekeeping, or for more advanced task flows that can free up time for more immediate concerns. There are even scripts that depend on Cron Jobs to run. The good thing is that such scripts will clearly detail what needs to be done with regard to the Cron Job.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/zalvis.com\/docs\/understanding-cron-jobs.html\/#How_Cron_Jobs_Work\" >How Cron Jobs Work?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/zalvis.com\/docs\/understanding-cron-jobs.html\/#Adding_Cron_Jobs_via_cPanel\" >Adding Cron Jobs via cPanel<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"How_Cron_Jobs_Work\"><\/span>How Cron Jobs Work?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A Cron Job is made of three parts:<\/p>\n<ul>\n<li>A script that is meant to run<\/li>\n<li>A command (specified in cPanel) that runs the script at set intervals or at set times.<\/li>\n<li>An action or result generated by the script, as the nature of the script might be.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Adding_Cron_Jobs_via_cPanel\"><\/span>Adding Cron Jobs via cPanel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li>Once you\u2019re logged in, under \u2018Advanced\u2019 in cPanel, select \u2018Cron Jobs\u2019 or type in \u2018Cron Jobs\u2019 on the top right Search bar.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-689\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8259.png\" alt=\"\" width=\"1437\" height=\"429\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8259.png 1437w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8259-300x90.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8259-1024x306.png 1024w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8259-768x229.png 768w\" sizes=\"auto, (max-width: 1437px) 100vw, 1437px\" \/><\/p>\n<ol start=\"2\">\n<li>For the next section, pick \u2018Cron Email\u2019, if you wish to get a report email every time the cron job runs. Then enter or confirm your existing, working email address (by default it uses the cPanel user email address).<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-690\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8260.png\" alt=\"\" width=\"1417\" height=\"444\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8260.png 1417w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8260-300x94.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8260-1024x321.png 1024w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8260-768x241.png 768w\" sizes=\"auto, (max-width: 1417px) 100vw, 1417px\" \/><\/p>\n<ol start=\"3\">\n<li>In \u2018Add New Cron Job\u2019 &gt; \u2018Common Settings\u2019, ensure that all settings meet your requirements.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-691\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8261.png\" alt=\"\" width=\"1411\" height=\"644\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8261.png 1411w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8261-300x137.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8261-1024x467.png 1024w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/06\/IMG_8261-768x351.png 768w\" sizes=\"auto, (max-width: 1411px) 100vw, 1411px\" \/><\/p>\n<ol start=\"4\">\n<li>You can choose specific time parameters for your Cron to run \u2013 from month all the way to minute.<\/li>\n<li>n \u2018Command\u2019, enter the command that you\u2019d like to run as a Cron Job.<\/li>\n<li>That\u2019s it. Just \u2018Add New Cron Job\u2019, and it will be added.<\/li>\n<\/ol>\n<p>Here in cPanel, you can also view all \u2018Current Cron Jobs\u2019 where, under the \u2018Action\u2019 column, you also get to \u2018Edit\u2019 or even \u2018Delete\u2019 any existing job.<\/p>\n<p>cURL, GET, and WGET<\/p>\n<p>Here\u2019s some good news when it comes to these request commands. As common as they are in Cron Jobs, there are no additional steps needed to access them; they\u2019re all enabled by default with us.<\/p>\n<p>To Keep in Mind for Running Cron Jobs<\/p>\n<ol>\n<li>Any such process will initially use the home directory to run.<\/li>\n<li>Since Cron processes do not generate an interactive command line, startup files like bashrc will not be accessed.<\/li>\n<li>If we name an executable file without a full path \u2013 either absolute or relative &#8211; the process will expect it to be in the \u2019bin\u2019 and \u2018usr\/bin\u2019 paths alone.<\/li>\n<li>For any script, the interpreter\u2019s location can be provided in one of two ways &#8211; a full path in a proper #! format or in the shell interface.<\/li>\n<li>All file locations must have full paths \u2013 absolute or relative, again.<\/li>\n<\/ol>\n<div class=\"gxzkf69e107aaeb457\" >If you enjoyed this article, then you\u2019ll love Zalvis's Cloud Hosting platform. Turbocharge your website and get 24\/7 support from our veteran team. Our world-class hosting infrastructure focuses on auto-scaling, performance, and security. Let us show you the Zalvis difference! <a href=\"https:\/\/zalvis.com\/\">Check out our services.<\/a><\/div><style type=\"text\/css\">\r\n@media screen and (min-width: 1201px) {\r\n.gxzkf69e107aaeb457 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 993px) and (max-width: 1200px) {\r\n.gxzkf69e107aaeb457 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 769px) and (max-width: 992px) {\r\n.gxzkf69e107aaeb457 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 768px) and (max-width: 768px) {\r\n.gxzkf69e107aaeb457 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (max-width: 767px) {\r\n.gxzkf69e107aaeb457 {\r\ndisplay: block;\r\n}\r\n}\r\n<\/style>\r\n","protected":false},"excerpt":{"rendered":"<p>When running a complex website, it makes sense to have a way of automating regular tasks, and never have to remind yourself to do them. This is what Cron Jobs is for \u2013 Linux commands that schedule things. That means, it is armed with a good knowledge of Linux commands, and you can make the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-686","post","type-post","status-publish","format-standard","hentry","category-cpanel-hosting"],"_links":{"self":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/comments?post=686"}],"version-history":[{"count":3,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/686\/revisions"}],"predecessor-version":[{"id":692,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/686\/revisions\/692"}],"wp:attachment":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/media?parent=686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/categories?post=686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/tags?post=686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}