Skip to content

Instantly share code, notes, and snippets.

@Dunedan Dunedan/respawn.sh
Last active Mar 24, 2017

Embed
What would you like to do?
Executes the command provided as argument and respawns it if it got terminated.
#!/bin/sh
# Executes the command provided as argument and respawns it if it got
# terminated.
#
# Licensed under CC0 <https://creativecommons.org/publicdomain/zero/1.0/>
$@ &
PID=$!
while :
do
sleep 1
if ! ps -p $PID > /dev/null; then
$@ &
PID=$!
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.