How to make my bash script as service in CentOS 7? following is failing.$ cat /etc/systemd/system/mybash.service[Unit]Description=mybash ServiceAfter=network.target[Service]Type=simpleUser=rootExecStart=/root/runme.shRestart=on-abort[Install]WantedBy=multi-user.target$ systemctl start mybash$ systemctl status mybash -lmybash.service - mybash Service   Loaded: loaded (/etc/systemd/system/mybash.service; disabled)   Active: inactive (dead).....$ cat /root/runme.sh #!/bin/bashecho Start the node servera=$(pgrep -f a.js);kill $a;a=$(pgrep -f b.js);kill $a;node /home/www/html/a.js &node /home/www/html/b.js &
CentOS 7 - why the service file is not working to run my bash script?
bash;centos;node.js
Do it properly.Don't use forever under service managers.  They already do this.Don't use pgrep and kill under service managers.  They do this better.Don't use start-stop-daemon under service managers.  They do this better.That entire mechanism with that shell script is wrongheaded to start with, and fixing its readiness protocol mismatch would be simply papering over some vast cracks.  You don't need any of that entire cobbled-together-poor-imitation-of-daemon-management script at all.  You have a service manager that can do that stuff directly and safely.  Use it.# /etc/systemd/system/node@.service[Unit]Description=node service for %i.jsDocumentation=https://unix.stackexchange.com/questions/207658/After=network.target[Service]Type=simpleExecStart=/usr/local/bin/node /home/www/html/%i.jsRestart=on-abortSyslogIdentifier=node-%i[Install]WantedBy=multi-user.targetFix the path to /usr/local/bin/node as appropriate.The usual commands then apply:systemctl preset node@a.service node@b.service systemctl start node@a.service node@b.service systemctl status node@a.service node@b.service Further readingFlix Saparelli (2013-11-26). How To Deploy Node.js Applications Using Systemd and Nginx.Ruben Vermeersch (2013-01-16). Deploying Node.js with systemd.https://unix.stackexchange.com/a/200365/5132https://askubuntu.com/a/625378/43344