How stop systemd service

roy picture roy · Nov 3, 2016 · Viewed 18.8k times · Source

I am trying to create systemd service file for Flume, have created /etc/systemd/system/flume-ng.service with following contents

[Unit]
Description=Apache Flume

[Service]
Environment=FLUME_CLASSPATH=/opt/flume/current/lib/
ExecStart=/usr/bin/nohup /usr/bin/flume-ng agent -c /etc/flume-ng/conf -f /etc/flume-ng/conf/flume.conf --name a1 &

[Install]
WantedBy=multi-user.target

which start the Flume service but how do I stop it as a service ?

In this case I had to kill with PID.

thanks

Answer

Umut picture Umut · Nov 4, 2016

You can just execute systemctl stop flume-ng.service. When executed, the default action is sending SIGTERM to the main process and wait until a configurable time to see if the processes has been terminated. If the process doesn't terminate, then systemd sends SIGKILL signal which does the job. If the main process has forked off other processes, systemd will take them down too since they all live in the same cgroup.

You do not need to have ExecStop= directive unless you have a different way of shutting down your service.