Search This Blog

Friday, 14 July 2017

Systemd service script example

#sudo vi  /etc/systemd/system/dummy_startup.service

               

[Unit]

Description=startup script


[Service]

ExecStart=/bin/su - ubuntu -c "/bin/bash /home/ubuntu/dummy_startup.sh"


[Install]

WantedBy=multi-user.target


  • Reload the systemctl service to update.

               

sudo systemctl daemon-reload


  • Starting the dummy_startup.service

           

sudo systemctl start dummy_startup.service


  • Checking the Status of Services of the  dummy_startup.service.


sudo systemctl status dummy_startup.service


  • Enabling  dummy_startup.service in runlevel.


sudo systemctl enable dummy_startup.service



Note:

If any changes made after dummy_startup.service file enabled as a service. It's required to reload the daemon by using the command "sudo systemctl daemon-reload"


In case of above solution doesn't fix the issue. It's required to disabled the service using command  "sudo systemctl disable dummy_startup.service" and re-enable it using "sudo systemctl enable dummy_startup.service"


No comments:

Post a Comment