Tag Archives: script

Linux : Add new startup script using Systemd

I has been working with current CentOS 7 using Systemd feature. Here is the script I use to start one of my program.

Create an empty file with name <what ever name>.service

Filename: runbind.service

Content of the file :

BOF >>>
[Unit]
Description=Runbind Reload
After=syslog.target
After=network.target


[Service]
Type=simple
User=root
Group=root
ExecStart=/bin/sh /opt/runbind.sh
Restart=always


# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300


[Install]
WantedBy=multi-user.target

<<<EOF

Save this file in /usr/lib/systemd/system/

Note: You will want to change this parameters :-

Please exclude BOF and EOF lines
User -> which user account you need to run this script
Group -> user’s group
ExecStart-> full path to your program or script
Description-> description of the script

Tested on CentOS Linux release 7.2.1511 (Core)

 

Credit to : 
https://www.redmine.org/boards/1/topics/32763?r=43267
https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples

 

Advertisements