Debian systemd run process at startup

This is a copy of: https://mkaz.github.io/2013/07/03/run-script-at-start-on-debian/ (because it disappeared).


Run Script at Start on Debian/Ubuntu




July 3, 2013



Updated: Dec 12, 2015



Determine Init System



Newer installs use systemd as the init system, which has a newer and more
consisten way to manage services. There was a lot of linux drama around this
change, my guess mostly due to "cheese moving" and having to learn something
new.



You can determine if your system is running systemd using: $ ps -p1



Start Daemon on System boot



The main reason I need this script is becaues BitTorrent Sync is not distributed as an Ubuntu package with necessary start scripts. Also, btsync needs to run as the user, which I often forget. First create the service file which describes how to start and information about the service.



Saved to: /etc/systemd/user/btsync.service


[Unit]
Description=BitTorrent Sync Service

[Service]
Type=forking
User=mkaz
ExecStart=/home/mkaz/bin/btsync --config /home/mkaz/.btsync.conf

[Install]
WantedBy=multi-user.target

Enable


sudo systemctl enable /etc/systemd/user/btsync.service



Start


sudo systemctl start btsync.service



That's it, it should be running now and each time you start. You can test by rebooting and confirming it works. The above is not ideal for multi-user servers, since I'm hardcoding everything to my user, adjust to your needs.



Extra



There is a lot more information available around systemd and a lot more
configuration available for example to execute a command before start, or other
dependencies.







Trackbacks

Trackback specific URI for this entry

This link is not meant to be clicked. It contains the trackback URI for this entry. You can use this URI to send ping- & trackbacks from your own blog to this entry. To copy the link, right click and select "Copy Shortcut" in Internet Explorer or "Copy Link Location" in Mozilla.

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA