I’m attempting to write a script in bash to run a script (run.sh) when a pgrep -f minecraft does not return anything.
!#/bin/bash
status=false
while :
do
pgrep -f minecraft && status=true
if $status = true; then
echo "up"
else
echo "down"
echo "restarting in 10 seconds, pres CTRL + C to cancel"
sleep 10
./run.sh
fi
done
This I expected to run run.sh when it could not find the process for minecraft.
Instead of detecting it live If the script is running and the process changes status, either grom existing to not or vice versa it will keep outputting what it was before the change.