Skip to content

Instantly share code, notes, and snippets.

@isidroamv
Last active December 8, 2017 20:02
Show Gist options
  • 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