Felipe Jhony Felipe Jhony - 3 months ago 9
Linux Question

How to make a systemctl unit (or service) start with system (on boot)

I have these options on my .service file:

[Unit]
Description=Atualizador de Sincronizacao

[Service]
TimeoutStartSec=0
ExecStart=/opt/sn_home/sincronizador/bin/jarupdater.sh


but it does not start with the system (like sshd does, for instance) so I need to run a "systemctl start" command every time.

What option do I need to add in this unit so it starts with the system?

Answer

Required the [Install] section on this unit where I added a WantedBy=multi-user.target so the service would start when the system starts.

Finally I had to enable the unit with the command that Marshall Whittaker gave me:

systemctl enable myservice.service