{"id":245,"date":"2012-07-24T15:17:12","date_gmt":"2012-07-24T15:17:12","guid":{"rendered":"http:\/\/scunster.co.uk\/?p=245"},"modified":"2012-11-25T20:13:25","modified_gmt":"2012-11-25T20:13:25","slug":"run-program-or-service-at-startup-ubuntu","status":"publish","type":"post","link":"https:\/\/scunster.co.uk\/?p=245","title":{"rendered":"Run program, or service at startup &#8211; Ubuntu"},"content":{"rendered":"<p>Easy way to run common programs or commands at startup \/ reboot using crontab<!--more--><\/p>\n<p>It&#8217;s useful because you can change directory as many times as you like in the script file without worrying about cron being able to use absolute paths etc.<\/p>\n<p>crontab -e<\/p>\n<p>@reboot \/home\/yourusername\/startup.sh<\/p>\n<p>Create the following file called startup.sh in your home directory<\/p>\n<p>This example auto loads Unreal IRC and it&#8217;s associated services, the sleep command makes the script pause for that number of seconds.<\/p>\n<p>You can add as many additional bash commands etc as you&#8217;d like and they should only start to load once the previous command has been successfully run (It may still be useful to use the sleep command for some programs \/ services)<\/p>\n<p># ======== PASTE THIS ============<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>PATH=\/usr\/sbin:\/usr\/bin:\/sbin:\/bin<\/p>\n<p># rest of script follows<\/p>\n<p>cd \/home\/youruser\/Unreal3.2\/<br \/>\n.\/unreal start<br \/>\nsleep 20<br \/>\ncd \/home\/youruser\/services\/<br \/>\n.\/services<\/p>\n<p># ========== END ==========<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Easy way to run common programs or commands at startup \/ reboot using crontab<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-245","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=245"}],"version-history":[{"count":3,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":453,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/245\/revisions\/453"}],"wp:attachment":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}