{"id":64,"date":"2013-02-12T00:31:22","date_gmt":"2013-02-12T00:31:22","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=64"},"modified":"2019-03-12T21:58:59","modified_gmt":"2019-03-12T21:58:59","slug":"how-to-setup-a-cron-job","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/how-to-setup-a-cron-job\/","title":{"rendered":"How to Setup a Cron Job"},"content":{"rendered":"<p>There are a couple ways to set up a cron job.\u00a0 If you have a script that you want to run ever so often, you could drop it in one of the cron directories, like cron.daily, or cron.weekly.\u00a0 These are located in \/etc.\u00a0 Another way to do it is to use crontab.<\/p>\n<p>To setup a cron job in crontab type<\/p>\n<pre>crontab -e<\/pre>\n<p>and then,<\/p>\n<pre>*\/30 * * * * \/path\/to\/yourscript.sh<\/pre>\n<p>The &#8220;*\/30&#8221;\u00a0 makes the script run every 30 minutes.\u00a0 Below gives you a better idea of how the line works.\u00a0 The asterisk (*) specifies all possible values for a field, but can\/should be replaced with the time you want the script to execute.<\/p>\n<pre>* * * * * command to be executed\n\n*(min) *(hr) *(DoM) *(month) *(week) \/path\/to\/command_or_script.sh\n<\/pre>\n<ul>\n<li>min= Minute 0 &#8211; 50<\/li>\n<li>hr = Hour 0-59<\/li>\n<li>DoM = Day of month 0-31<\/li>\n<li>month = Month 1-12<\/li>\n<li>week = Day of Week 0-7, Sunday is 0 or 7<\/li>\n<\/ul>\n<p>Below are a couple of examples of how to run a script or command.<br \/>\nEvery minute.<\/p>\n<pre>* * * * * \/path\/to\/script.sh<\/pre>\n<p>Every day 10 minutes after 1 in the morning,<\/p>\n<pre>10 1 * * * \/path\/to\/command<\/pre>\n<p>Also, if you don&#8217;t want to be emailed the output of the command, you can simple append &#8220;&gt;\/dev\/null 2&gt;&amp;1&#8221; to the end of the crontab line.<br \/>\nExample<\/p>\n<pre>0 * 1 * * \/path\/to\/command\/ &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are a couple ways to set up a cron job.\u00a0 If you have a script that you want to run ever so often, you could drop it in one of the cron directories, like cron.daily, or cron.weekly.\u00a0 These are &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/how-to-setup-a-cron-job\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,32,3],"tags":[276,34,33,35,7],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-command-line","category-cron-linux","category-linux","tag-cron","tag-cron-job","tag-crontab","tag-how-to","tag-linux-2"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":3,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":2378,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/64\/revisions\/2378"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}