Created
August 10, 2023 19:25
-
-
Save danielestevez/46d46711d72fef46d95f890aa3624ad5 to your computer and use it in GitHub Desktop.
Keep alive Bash script to check, log and restart a process
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/bash | |
process_name="xxxxx" | |
if ! pgrep -x "$process_name" > /dev/null; then | |
echo "The process $process_namen was not running at " $(date -u) >> ~/keep_alive.log | |
./xxxxxx & | |
echo "The process $process_namen was restarted at " $(date -u) >> ~/keep_alive.log | |
fi | |
# crontab expression to run check every 5 mins | |
# */5 * * * * ./keep_alive.sh >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment