Last active
October 6, 2016 07:22
-
-
Save hex2010/5859c0ec2ec02c66000641836ba64dc7 to your computer and use it in GitHub Desktop.
Auto relaunch specific application when it crash. (MacOS)
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 | |
# you can setup crontab to run this script periodically | |
# require pidof install in /usr/local/bin | |
# read config from ~/.bgapp | |
ret=0 | |
while read s; do | |
IFS="|"; cfg=($s) ; unset IFS; | |
if [ "${#cfg[@]}" = "2" ]; then | |
if [ -z "`/usr/local/bin/pidof ${cfg[0]}`" ]; then | |
# echo "launch \"${cfg[0]}\": ${cfg[1]} &" | |
osascript -e "display notification \"launch \\\"${cfg[0]}\\\"\" with title \"bgapp\"" | |
eval "${cfg[1]}" | |
fi | |
elif [ -n "$s" ]; then | |
echo "Invalid line in ~/.bgapp : \"\"" | |
ret=1 | |
fi | |
#echo $? | |
done < $HOME/.bgapp | |
exit $ret |
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
# assume you place bgapp in $HOME/bin | |
* * * * * $HOME/bin/bgapp.sh |
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
Spectacle|open -a Spectacle | |
BitBar|open -a BitBar | |
mongod|mongod --fork --syslog | |
godoc|nohup ~/bin/godoc -http=:12345 & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for MacOS