Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill old instance of phantomjs by monit

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.

like image 944
ironsand Avatar asked Jul 05 '15 05:07

ironsand


1 Answers

Use a timestamp on each instance then use:

.quit()

On the oldest instance?

This method kills the instance and all resources.

like image 168
Robert Pounder Avatar answered Oct 09 '22 06:10

Robert Pounder