Skip to content

Instantly share code, notes, and snippets.

@dansku
Created February 17, 2018 02:09
Show Gist options
  • Save dansku/83cbc8ff08c951ba58a2c3f02d68c3c8 to your computer and use it in GitHub Desktop.
Save dansku/83cbc8ff08c951ba58a2c3f02d68c3c8 to your computer and use it in GitHub Desktop.
restarting script when it crashes
#!/bin/sh
COMMAND='python /home/runcloud/parser/live.py'
LOGFILE=restart.txt
writelog() {
now=`date`
echo "$now $*" >> $LOGFILE
}
writelog "Starting"
while true ; do
$COMMAND
writelog "Exited with status $?"
writelog "Restarting"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment