I'm trying to setup a systemd unit that should restart a bash script if it fails.
[Unit]
Description=Bash script Service
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/bin/bash -c '/simple/bash/script.sh'
But from systemctl status the_bash_script.service it seems that it is started with multiple instances:
● the_bash_script.service - Bash script Service
Loaded: loaded (/etc/systemd/system/the_bash_script.service; static; vendor preset: enabled)
Active: active (running) since Thu 2016-11-03 18:16:53 CET; 3 years 6 months ago
Main PID: 1766 (bash)
CGroup: /system.slice/the_bash_script.service
├─1766 /bin/bash -c '/bin/bash -c '/simple/bash/script.sh'
└─1778 /bin/bash -c '/bin/bash -c '/simple/bash/script.sh'
Why there are 2 pids 1766 and 1778? Can I allow only one instance at time?
If this is the content of the_bash_script.service I don't need thata multiple instance are run at the same time:
#!/bin/bash
while [ true ]; do
cat /dev/virtual | nc -v 192.168.1.1 5005
sleep 5s
done
exit