{"id":129,"date":"2016-04-30T22:16:22","date_gmt":"2016-05-01T03:16:22","guid":{"rendered":"https:\/\/servertricks.com\/?p=129"},"modified":"2016-05-05T10:37:03","modified_gmt":"2016-05-05T15:37:03","slug":"how-to-setup-a-cron-job","status":"publish","type":"post","link":"https:\/\/servertricks.com\/index.php\/2016\/04\/30\/how-to-setup-a-cron-job\/","title":{"rendered":"How to Setup a Cron Job"},"content":{"rendered":"<p>Put a shell script in one of these folders: \/etc\/cron.daily, \/etc\/cron.hourly, \/etc\/cron.monthly or \/etc\/cron.weekly.<\/p>\n<p>If these are not enough for you you can add more specific tasks eg. twice a month or every 5 minutes or&#8230; go to the terminal and type:<\/p>\n<p><code>$ crontab -e<\/code><\/p>\n<p>this will open your personal crontab (cron configuration file), the first line in that file explains it all (don&#8217;t you think)! In every line you can define one command to run, and the format is quite simple when you get the hang of it. So the structure is:<\/p>\n<p>minute hour day-of-month month day-of-week command<br \/>\nFor all the numbers you can use lists eg, 5,34,55 in the first field will mean run at 5 past 34 past and 55 past what ever hour is defined.<\/p>\n<p>You can also use intervals, they are defined like this: *\/20 this example means every 20th and if in the minutes column this will be equivalent to 0,20,40<br \/>\nSo to run a command every monday at 5:30 in afternoon:<\/p>\n<p><code> $ 30 17 * * 1 \/path\/to\/command<\/code><\/p>\n<p>or every 15 minutes<\/p>\n<p><code>*\/15 * * * * \/path\/to\/command<\/code><\/p>\n<p>Note that the day-of-week goes from 0-7 where 0=7 is sunday.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Put a shell script in one of these folders: \/etc\/cron.daily, \/etc\/cron.hourly, \/etc\/cron.monthly or \/etc\/cron.weekly. If these are not enough for you you can add more specific tasks eg. twice a month or every 5 minutes or&#8230; go to the terminal and type: $ crontab -e this will open your personal crontab (cron configuration file), the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[11,10],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-ubuntu","tag-14-04","tag-16-04"],"_links":{"self":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":3,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/posts\/129\/revisions\/165"}],"wp:attachment":[{"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/servertricks.com\/index.php\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}