Monday, May 28, 2018

systemctl start service on boot with specific user

see https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units


sudo vi /etc/systemd/system/ms.service

[Unit]
Description=myservice

[Service]
User=myuser
ExecStart=/bin/bash /path/to/script/ms.sh start
ExecStop=/bin/bash /path/to/script/ms.sh stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target


sudo chmod 744 /etc/systemd/system/ms.service

sudo systemctl enable ms.service

(this should give you "Created symlink from /etc/systemd/system/multi-user.target.wants/ms.service to /etc/systemd/system/ms.service." )

How to troubleshoot? https://www.certdepot.net/systemd-service-debugging-tips/


systemctl start ms
systemctl status ms
journalctl -u ms


No comments: