Last active
March 24, 2017 17:52
-
-
Save Dunedan/698648b86298ee15900f to your computer and use it in GitHub Desktop.
Executes the command provided as argument and respawns it if it got terminated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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