Skip to content

Instantly share code, notes, and snippets.

@danny8376
Created December 12, 2023 15:45
Show Gist options
  • Save danny8376/681dbf86fdd0e6ec48145b343ce07b53 to your computer and use it in GitHub Desktop.
Save danny8376/681dbf86fdd0e6ec48145b343ce07b53 to your computer and use it in GitHub Desktop.
#!/bin/sh
DELAY=1
PID=0
trap_int() {
if [ "$PID" = "0" ]; then
exit
else
kill -TERM $PID
fi
}
trap trap_int 2 # SIGINT
while true; do
"WHATEVER" &
PID=$!
wait $PID
PID=0
echo Restart after $DELAY seconds...
sleep $DELAY
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment