{"id":183,"date":"2014-08-17T20:50:50","date_gmt":"2014-08-17T20:50:50","guid":{"rendered":"http:\/\/www.n4n.us\/wordpress\/?p=183"},"modified":"2014-08-17T21:02:16","modified_gmt":"2014-08-17T21:02:16","slug":"raspberry-pi-and-cron","status":"publish","type":"post","link":"https:\/\/www.n4n.us\/wordpress\/?p=183","title":{"rendered":"Raspberry Pi and Cron"},"content":{"rendered":"<p>After two days of attempting to get Cron to execute tasks (in this case shell scripts) on a Raspberry PI, I finally got it working.<\/p>\n<p>I must have read\u00a0at least three dozen sites and all my Raspberry Pi books in my attempts, nothing work..<\/p>\n<p>Here are some of the suggestions I found.<\/p>\n<p>This one states it will edit the users cron file:<\/p>\n<blockquote><p>pi@raspberry ~ $ crontab -e<\/p><\/blockquote>\n<p>This one states it will display all the users schedule cron tasks:<\/p>\n<blockquote><p>pi@raspberry ~ $ crontab -l<\/p><\/blockquote>\n<p>I did find these useful:<\/p>\n<blockquote><p>pi@raspberry ~ $ \/etc\/init.d\/cron stop<\/p>\n<p>pi@raspberry ~ $\u00a0\/etc\/init.d\/cron start<\/p>\n<p>pi@raspberry ~ $\u00a0\u00a0\/etc\/init.d\/cron restart<\/p><\/blockquote>\n<p>But none triggered my script to run, then in my notes, from a past project I found:<\/p>\n<blockquote><p>pi@raspberry ~ $\u00a0<!--?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?--> <span style=\"color: #000000;\">sudo nano \/etc\/crontab\u00a0<\/span><\/p><\/blockquote>\n<p>This allowed me to edit the system cron task list..<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<blockquote><p># \/etc\/crontab: system-wide crontab<\/p>\n<p># Unlike any other crontab you don&#8217;t have to run the `crontab&#8217;<\/p>\n<p># command to install the new version when you edit this file<\/p>\n<p># and files in \/etc\/cron.d. These files also have username fields,<\/p>\n<p># that none of the other crontabs do.<\/p>\n<p>SHELL=\/bin\/sh<\/p>\n<p>PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin<\/p>\n<p># m h dom mon dow user\u00a0 command<\/p>\n<p>17 *\u00a0 \u00a0 * * * \u00a0 root\u00a0 \u00a0 cd \/ &amp;&amp; run-parts &#8211;report \/etc\/cron.hourly<\/p>\n<p>25 6\u00a0 \u00a0 * * * \u00a0 root\u00a0 \u00a0 test -x \/usr\/sbin\/anacron || ( cd \/ &amp;&amp; run-parts &#8211;repo$<\/p>\n<p>47 6\u00a0 \u00a0 * * 7 \u00a0 root\u00a0 \u00a0 test -x \/usr\/sbin\/anacron || ( cd \/ &amp;&amp; run-parts &#8211;repo$<\/p>\n<p>52 6\u00a0 \u00a0 1 * * \u00a0 root\u00a0 \u00a0 test -x \/usr\/sbin\/anacron || ( cd \/ &amp;&amp; run-parts &#8211;repo$<\/p>\n<p>10 * * * * pi cd \/home\/pi &amp;&amp; .\/jabberfix.sh<\/p>\n<p>#<\/p><\/blockquote>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>The last task, which runs at 10 minutes after the hour, for user pi, fixes my jabber connection.<\/p>\n<p>Honestly, I have no clue what the other tasks are doing. More research! But I am very happy I now know how to add my own tasks to cron.<\/p>\n<p>Enjoy<\/p>\n<p>~David<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After two days of attempting to get Cron to execute tasks (in this case shell scripts) on a Raspberry PI, I finally got it working. I must have read\u00a0at least three dozen sites and all my Raspberry Pi books in my attempts, nothing work.. Here are some of the suggestions I found. This one states &hellip; <a href=\"https:\/\/www.n4n.us\/wordpress\/?p=183\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Raspberry Pi and Cron&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,21],"tags":[],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-projects","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=183"}],"version-history":[{"count":4,"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/183\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.n4n.us\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}