I'd like to restart a program regardless of it already running or not using crontab.
I have this in crontab -e
* * * * * /usr/bin/pkill -f myapp; /home/ubuntu/xyz/bin/res.sh
And in the res.sh
#!/bin/bash
/usr/bin/pkill -f myapp
sleep 10
/home/ubuntu/xyz/bin/myapp & &>/dev/null
The problem is if the program is running, it kills the program. but it fails to start the program again.
I don't want to use any condition as to check if the program is already running and start only if it's not.
EDIT: The program is not a service to use "/etc/init.d/service restart" or "sudo service myapp restart"
Thanks.