{"id":1089,"date":"2018-10-13T12:31:05","date_gmt":"2018-10-13T03:31:05","guid":{"rendered":"https:\/\/manatails.net\/blog\/?p=1089"},"modified":"2022-04-03T13:48:53","modified_gmt":"2022-04-03T04:48:53","slug":"adding-a-startup-script-as-a-service-in-ubuntu","status":"publish","type":"post","link":"https:\/\/manatails.net\/blog\/2018\/10\/adding-a-startup-script-as-a-service-in-ubuntu\/","title":{"rendered":"Adding a startup script as a service in Ubuntu"},"content":{"rendered":"<p>I write this up because I don&#8217;t want to look it up everytime I need it. This will create a simple service that executes a script in Ubuntu systemd.<\/p>\n<p>&nbsp;<\/p>\n<p>1. Create a file: \/etc\/systemd\/system\/service-name.service<\/p>\n<pre class=\"prettyprint\">[Unit]\r\nDescription=Some Description of your service\r\nAfter=network.target\r\nAfter=systemd-user-sessions.service\r\nAfter=network-online.target\r\n\r\n[Service]\r\nUser=root\r\nType=simple\r\nExecStart=\/path\/to\/your\/script\/start-all.sh\r\nRestart=on-failure\r\nRestartSec=30\r\nStartLimitInterval=350\r\nStartLimitBurst=10\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\n<p>2. Reload systemd<\/p>\n<pre class=\"prettyprint\">systemctl daemon-reload<\/pre>\n<p>3. Make that your script executable with:<\/p>\n<pre class=\"prettyprint\">chmod u+x \/path\/to\/your\/script\/start-all.sh<\/pre>\n<p>4. Start it:<\/p>\n<pre class=\"prettyprint\">sudo systemctl start service-name<\/pre>\n<p>5. Enable it to run at boot<\/p>\n<pre class=\"prettyprint\">sudo systemctl enable service-name<\/pre>\n<p>tip: #!\/bin\/sh is necessary at the beginning of the script or startup will fail with error 203<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I write this up because I don&#8217;t want to look it up everytime I need it. This will create a simple service that executes a script in Ubuntu systemd. &nbsp; 1. Create a file: \/etc\/systemd\/system\/service-name.service [Unit] Description=Some Description of your service After=network.target After=systemd-user-sessions.service After=network-online.target [Service] User=root Type=simple ExecStart=\/path\/to\/your\/script\/start-all.sh Restart=on-failure RestartSec=30 StartLimitInterval=350 StartLimitBurst=10 [Install] WantedBy=multi-user.target 2. &hellip; <a href=\"https:\/\/manatails.net\/blog\/2018\/10\/adding-a-startup-script-as-a-service-in-ubuntu\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Adding a startup script as a service in Ubuntu<\/span> <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":[8],"tags":[124],"class_list":["post-1089","post","type-post","status-publish","format-standard","hentry","category-computer","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts\/1089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/comments?post=1089"}],"version-history":[{"count":2,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts\/1089\/revisions"}],"predecessor-version":[{"id":1129,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts\/1089\/revisions\/1129"}],"wp:attachment":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/media?parent=1089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/categories?post=1089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/tags?post=1089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}