1

I have a bash script that is written in a debian-based distribution (System-V) and I want to run it under CentOS 7. There is a part of the script that runs a command as a daemon like this:

start-stop-daemon --start --pidfile $PIDFILE \
 --chdir "$DIR" --startas $PROGRAM --name foo --chuid "$USER" -- $ARGS

And stops the daemon like this:

start-stop-daemon --stop --quiet --pidfile $PID \
                  --user "$USER" --name foo --retry=TERM/30/KILL/5

My question is how do something equivalent in CentOS 7? Is the daemon function in /etc/init.d/functions an alternative?

3bdalla
  • 441

1 Answers1

1

The daemon() shell function from /etc/rc.d/init.d/functions on RHEL/CentOS 6 is not an exact equivalent of Debian's start-stop-daemon. The fact that all of these van Smoorenburg rc tool libraries have subtly different helper command sets is one of the well-known problems with van Smoorenburg rc.

You're using CentOS 7. You have systemd. Write a systemd service unit.

Further reading

JdeBP
  • 68,745