How to implement a Linux daemon in bash that can be start/stop by `sudo service`?

Ralf Mardorf silver.bullet at zoho.com
Mon Feb 12 09:18:50 UTC 2018


On Mon, 12 Feb 2018 08:59:36 +0000, Colin Law wrote:
>On 12 February 2018 at 00:16, Peng Yu <pengyu.ut at gmail.com> wrote:
>> Hi,
>>
>> There are a lot of resource about creating Linux daemon. But I am not
>> sure which is one is the most correct and provide the essential
>> things for a Linux daemon in bash that can be start/stop by `sudo
>> service`? Would anybody point me the best resource to learn how to
>> create such a daemon? Thanks.  
>
>On recent Ubuntu systems systemd is used to control such things. It is
>easy to write systemd scripts unless the requirements for you daemon
>are complex. Google for systemd script tutorials to get you going.

Or else write a script and don't care about the init system at all and
when you finished the script, read how to edit a systemd unit. Instead
of learning the rocket sience explained by e.g.
https://www.freedesktop.org/software/systemd/man/systemd.service.html
https://www.freedesktop.org/software/systemd/man/systemd.unit.html
consider to take a look at the systemd units provided by packages, doing
something similar as your scrip.





More information about the ubuntu-users mailing list