3

I am trying to monitor if certain application has killed, crashed, force killed on system. How can I get such notifications on Mac.

What is the common approach to implement such design?

Thank you

RLT
  • 4,219
  • 4
  • 37
  • 91
  • Why do you need to know? If it's your app that you want to monitor, put the app in as a service and let the system restarts it. – Black Frog Jul 24 '11 at 18:36
  • I am trying to monitor other processes running on system. – RLT Jul 25 '11 at 08:46
  • Possible duplicate of [Programmatically check if a process is running on Mac](http://stackoverflow.com/questions/2518160/programmatically-check-if-a-process-is-running-on-mac) – Black Frog Jul 25 '11 at 11:51
  • No its not duplicate of it. I dont know the process name. I want a service kind of thing which can notify if any process on system has been has killed, crashed, force killed. – RLT Jul 25 '11 at 12:24

2 Answers2

4

Observing Process Lifetimes Without Polling

RLT
  • 4,219
  • 4
  • 37
  • 91
0

I believe the common approach, although probably not exactly what you're looking for, is to periodically poll your processes. For instance:

ps -A | grep 'someIndentifingString'

If this doesn't return anything, your process is gone.

This won't, though, tell you if it was caused by a crash, force kill etc., so I'm not sure that it completely meets your needs.

Roy Truelove
  • 22,016
  • 18
  • 111
  • 153
  • Polling approach may work. But I am not trying to monitor my process, I am trying to monitor other processes running on system. Something which activity monitor does(not exactly). – RLT Jul 25 '11 at 08:45
  • 'ps -A' should give you all of the processes running on the machine, not just your own. EDIT - just saw your comment above - sounds like you're looking for if *any* processes is killed, not a specific process - if that's true then you're correct - polling won't cut it. – Roy Truelove Jul 25 '11 at 13:21