I'm trying to load a script on boot in Ubuntu Server 18.04.
My .service script is installed in /etc/systemd/system, and I can
service my-service start
service my-service stop
but when I try to run at boot (which according to the web I should do) with
service my-service enable
the system responds with
my-service: unrecognised service
Searching the web only tells me how to do it in older versions of Ubuntu which do not apply to 18.04 and I am unable to determine the correct terminology to find the answer.
# filename: /etc/systemd/system/my-service.service [Unit] Description=My Service After=network.target After=mysqld.service [Service] User=the-user WorkingDirectory=/home/the-user/path-to-script ExecStart=/home/the-user/path-to-script/start.sh SuccessExitStatus=0 TimeoutStopSec=10 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
The question (obviously) is: What am I doing wrong? How can I start this service on boot?
Thanks in advance
Use the real command, which for systemd would be:
sudo systemctl enable my-service
For reference, you do not have to use the main system directory for the unit file if you want it to run for a normal user, e.g. your own. You can create it in a directory such as:
Then you can do:
systemctl --user enable my-service
This avoids the need for