For a student environment, I have a simple bash script that runs upon boot up on Ubuntu 18.04 (@reboot in crontab -e).
It runs ok (java file starts, netcat starts, pings, and all PIDs are viewable via "ps -aux"), but I would like to make this more "bullet proof", if possible.
Is there anything I can put in this Bash script to monitor the PIDs that are created and then dynamically generate them again if they stop running or are killed?
#!/bin/bash
echo myPassword | sudo -S service simulatord start &&
nc -k -l 2214 &
nc -k -l 3612 &
ping -i 290 192.168.0.101 &
ping -i 290 10.10.3.254 &
This scripts starts a simulation program (simulatord) and then runs the following commands in parallel in the background.
Ideally I can put some logic in this Bash script that would allow me to "kill -9" the ping or nc PID and then have it respawn, but I'm unsure if this is doable in Bash or if I need a different tool (Python script?)