Skip to content

Instantly share code, notes, and snippets.

@isidroamv
Last active December 8, 2017 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isidroamv/2a4ebf357edad0ab24d3832c8b73b485 to your computer and use it in GitHub Desktop.
Save isidroamv/2a4ebf357edad0ab24d3832c8b73b485 to your computer and use it in GitHub Desktop.
Restart process if crash on Linux
#!/bin/bash
# Add this file as a crontab task
# Example: * * * * * bash /opt/dir/task/stayalive.sh
# If the collector is not runing, execute it
if [[ ! `pgrep -f "python main.py"` ]]; then
cd /opt/dir/process && ./process-name
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment