{"id":1178,"date":"2025-03-09T15:07:27","date_gmt":"2025-03-09T05:07:27","guid":{"rendered":"https:\/\/nickdu.com\/?p=1178"},"modified":"2025-03-09T15:07:29","modified_gmt":"2025-03-09T05:07:29","slug":"linux-note-how-to-start-an-application-automatically-on-boot","status":"publish","type":"post","link":"https:\/\/nickdu.com\/?p=1178","title":{"rendered":"Linux note: How to start an application automatically on boot"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>Modify <code>\/etc\/rc.d\/rc.local<\/code> file<\/li>\n<\/ul>\n\n\n\n<p>If you wish to add a new service to start when the machine boots you should add the necessary script to the directory\u00a0<code>\/etc\/init.d\/<\/code>. Many of the scripts already present in that directory will give you an example of the kind of things that you can do.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Newer versions of linux\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Systemd#Adoption\">support<\/a>\u00a0<code>systemd<\/code>. \u00a0It has more features and is more portable than debian-specific solution.<\/li>\n<\/ul>\n\n\n\n<p>sample script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=Example systemd service.\n\n&#91;Service]\nType=simple\nExecStart=\/bin\/bash \/path\/to\/myscript.sh\n\n&#91;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Using\u00a0<code>crontab<\/code><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$ crontab -e\n\n@reboot \/home\/nick\/auto_run_script.sh<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you wish to add a new service to start when the machine boots you should add the necessary script to the directory\u00a0\/etc\/init.d\/. Many of the scripts already present in that directory will give you an example of the kind of things that you can do. sample script:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1178","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/1178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1178"}],"version-history":[{"count":1,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/1178\/revisions"}],"predecessor-version":[{"id":1179,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/1178\/revisions\/1179"}],"wp:attachment":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}