On Thu, Feb 19, 2009 at 12:49:03PM -0600, Scott Granneman wrote: > > I want to test if a process is running on our Mac OS X Server: Frontier. > > If it's running, great. > > If it's not running, I want to start it. > > Am I correct that this should work? > > ps aux | grep [F]rontier || /Applications/Frontier/Qaliva\ > Frontier.app/Contents/MacOS/Qaliva\ Frontier & > > Why [F]rontier? It's a trick to make sure that the grep doesn't show > up a false positive. > > Does anyone see any reason why this should not work? 'cause it appears > not to be working like it should, and that makes me sad.
If I recall correctly, the ps on Mac OS X uses terminfo to determine how many characters to print on each line, even if you are piping to another application. If Frontier does not appear in the characters printed in the width of your screen, the grep will not see it. Try running it from a terminal windows that has been maximized. This issue led me to change my psg alias to alias psg='ps A | grep -v grep | grep -E -i' Now, what happens when you run this from a cron? Maybe it will just work since there should not be a terminal associated with it. -- David Dooling http://www.politigenomics.com/ --~--~---------~--~----~------------~-------~--~----~ Central West End Linux Users Group (via Google Groups) Main page: http://www.cwelug.org To post: [email protected] To subscribe: [email protected] To unsubscribe: [email protected] More options: http://groups.google.com/group/cwelug -~----------~----~----~----~------~----~------~--~---
