Skip to content

Instantly share code, notes, and snippets.

@lusentis
Last active January 3, 2016 08:29
Show Gist options
  • Save lusentis/8436391 to your computer and use it in GitHub Desktop.
Save lusentis/8436391 to your computer and use it in GitHub Desktop.
Run a script forever, optionally executing a setup.sh script after each restart.
#!/bin/bash
## forever.sh
#
# Run a script forever,
# optionally executing a setup.sh
# script after each restart.
#
SLEEP_TIME=5
if [[ -z "$FOREVERSH_CMD" ]]; then
echo "Usage: FOREVERSH_CMD=\"cmd to execute --args\" $0"
exit 1
fi
echo "Forever running command $FOREVERSH_CMD."
while [[ true ]]; do
$FOREVERSH_CMD
sleep $SLEEP_TIME
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment