{"id":190,"date":"2016-05-21T05:58:55","date_gmt":"2016-05-21T09:58:55","guid":{"rendered":"http:\/\/teakdata.com\/blog\/?p=190"},"modified":"2017-05-03T17:29:58","modified_gmt":"2017-05-03T21:29:58","slug":"raspberry-pi-start-program-boot","status":"publish","type":"post","link":"https:\/\/teakdata.com\/blog\/raspberry-pi-start-program-boot\/","title":{"rendered":"RaspberryPi start program on boot"},"content":{"rendered":"<h1>RaspberryPi start program on boot<\/h1>\n<p>Using raspberry-pi as an autonomous device will require automatic execution of your programs at boot time. \u00a0In this post we will explain a way\u00a0to setup the raspberry-pi device to run programs automatically on boot.<\/p>\n<p><a href=\"http:\/\/teakdata.com\/blog\/wp-content\/uploads\/2015\/04\/RaspberyPi.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-109\" title=\"RaspberryPi start program on boot\" src=\"http:\/\/teakdata.com\/blog\/wp-content\/uploads\/2015\/04\/RaspberyPi.gif\" alt=\"RaspberryPi start program on boot\" width=\"135\" height=\"92\" \/><\/a><!--more--><\/p>\n<h2>Auto start programs using\u00a0\/etc\/rc.local<\/h2>\n<p>Edit the\u00a0\/etc\/rc.local file<\/p>\n<pre>sudo nano \/etc\/rc.local<\/pre>\n<p>Important:<\/p>\n<ul>\n<li>If your command runs continuously (for example running the <a href=\"http:\/\/teakdata.com\/blog\/diy-home-security-system-using-raspberry-pi\/\">door security project<\/a>), be sure to end the command with an &#8220;&amp;&#8221; \u00a0(that will allow execution as a new process \u00a0&#8211; fork)<\/li>\n<li>Reference the absolute filename instead of\u00a0relative path to your home folder; for example \u00a0<strong><em>\/home\/pi\/doorsensor-1.0.0-SNAPSHOT\/door.sh<\/em><\/strong>\u00a0\u00a0rather than <em><strong>door.sh<\/strong><\/em>\u00a0.<\/li>\n<\/ul>\n<p>Example of rc.local<\/p>\n<pre>#!\/bin\/sh -e\r\n#\r\n# rc.local\r\n#\r\n# This script is executed at the end of each multiuser runlevel.\r\n# Make sure that the script will \"exit 0\" on success or any other\r\n# value on error.\r\n#\r\n# In order to enable or disable this script just change the execution\r\n# bits.\r\n#\r\n# By default this script does nothing.\r\n\r\n# Print the IP address\r\n_IP=$(hostname -I) || true\r\nif [ \"$_IP\" ]; then\r\n printf \"My IP address is %s\\n\" \"$_IP\"\r\nfi\r\n\r\nsudo \/home\/pi\/doorsensor-1.0.0-SNAPSHOT\/door.sh &amp;\r\n\r\nexit 0<\/pre>\n<p class=\"p1\">Reference documentation:\u00a0<a href=\"https:\/\/www.raspberrypi.org\/documentation\/linux\/usage\/rc-local.md\">https:\/\/www.raspberrypi.org\/documentation\/linux\/usage\/rc-local.md<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RaspberryPi start program on boot Using raspberry-pi as an autonomous device will require automatic execution of your programs at boot time. \u00a0In this post we will explain a way\u00a0to setup the raspberry-pi device to&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":122,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12,10],"tags":[7,8,3,9],"class_list":["post-190","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-daniel-dad-laboratories","category-education","category-linux","category-raspberrypi","tag-autostart","tag-boot","tag-raspberry-pi","tag-script"],"_links":{"self":[{"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":17,"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions\/240"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/media\/122"}],"wp:attachment":[{"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teakdata.com\/blog\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}