7

I have a program that using phantomjs. There should be only a instance for the program and there is no program using Phantomjs.

But sometimes Phantomjs are launched several instances sametime. Probably my program have a bug. For quick fix I want to kill old instance if there are Phantomjs instance more than one by monit.

I can find the instances of Phantomjs by using matching function in monit. But I couldn't find out how to compare two instance status and kill old one.

I'd be very grateful for any advice.

ironsand
  • 14,329
  • 17
  • 83
  • 176

1 Answers1

1

Use a timestamp on each instance then use:

.quit()

On the oldest instance?

This method kills the instance and all resources.

Robert Pounder
  • 1,490
  • 1
  • 14
  • 29
  • Thanks for answer, but I want to know how to compare the time stamps of multiple instance in monit, not the way how to kill the instance. Or am I misunderstanding your answer? – ironsand Jul 16 '15 at 22:21