I am trying to create a very simple systemd unit service, in attemp to manage "iperf" (bandwidth measurement tool).
I installed iperf with yum and created this file:
If I run systemctl start iperf, it hangs and I never return to bash. Anyway, service is started:# cat /etc/systemd/system/iperf.service
[Unit]
Description=iperf
After=network.target
[Service]
ExecStart=/usr/bin/iperf -s -D
ExecStop=/usr/bin/killall -9 iperf
Type=forking
PIDFile=/var/run/iperf.pid
[Install]
WantedBy=default.target
# systemctl status iperf
● iperf.service - iperf
Loaded: loaded (/etc/systemd/system/iperf.service; disabled; vendor preset: disabled)
Active: activating (start) since Wed 2019-05-08 21:52:46 CEST; 4s ago
Process: 18776 ExecStart=/usr/bin/iperf -s -D (code=exited, status=0/SUCCESS)
CGroup: /system.slice/iperf.service
└─18777 /usr/bin/iperf -s -D
May 08 21:52:46 jus systemd[1]: Starting iperf...
May 08 21:52:46 jus iperf[18776]: Running iperf
May 08 21:52:46 jus systemd[1]: PID file /var/run/iperf.pid not readable (yet?) after start.
I also tried with Type=simple, this way service seems to start, but I get:# ps aux |grep iperf
root 18770 0.0 0.0 134820 1292 pts/2 S+ 21:52 0:00 systemctl start iperf
root 18777 0.0 0.0 98952 412 ? Ssl 21:52 0:00 /usr/bin/iperf -s -D
root 18783 0.0 0.0 112708 944 pts/0 S+ 21:53 0:00 grep --color=auto iperf
systemctl status iperf
● iperf.service - Iperf Bandwidth Test Service
Loaded: loaded (/etc/systemd/system/iperf.service; disabled; vendor preset: disabled)
Active: inactive (dead)
May 08 21:54:16 jus systemd[1]: iperf.service start operation timed out. Terminating.
May 08 21:54:16 jus systemd[1]: Failed to start iperf.
May 08 21:54:16 jus systemd[1]: Unit iperf.service entered failed state.
May 08 21:54:16 jus systemd[1]: iperf.service failed.
May 08 21:54:33 jus systemd[1]: Started iperf.
May 08 21:54:33 jus iperf[18815]: Running Iperf Server as a daemon
May 08 21:54:49 jus systemd[1]: Started iperf.
May 08 21:54:49 jus iperf[18834]: Running Iperf Server as a daemon
May 08 21:55:18 jus systemd[1]: Started iperf.
May 08 21:55:18 jus iperf[18870]: Running Iperf Server as a daemon
What is my error?
Thank you!