I'm have a process on my system which is notorious for crashing, and is kind of mission critical, my network manager. In any case, I need to write a loop which tests if it's running and starts it if it isn't. This is what I've come up with thus far:
#!/bin/bash while [ true ]; do if [ -z $(ps aux | grep "[n]m-applet") ]; then echo "Bugger died, resurrecting..." nm-applet >/dev/null 2>/dev/null & disown $! fi sleep 3 done
Unfortunately, this isn't quite doing the trick, as it seems to be starting the process even when not necessary, and after the first run, I get the following error output:
line 4: [: too many arguments
What am I doing wrong here?