H2 stop and restart an app from cron?

James Bond

Registered
I have an application that has a memory leak....it runs OK for two or even three days but then it starts to take up lots of memory (cf top) and slows the system down with paging.

I would like to have some way to automatically kill it every day (say) and restart it but how to do that? I guess I need some job which I can run from cron (I know how to do this)....but how to find the PID and do the "kill -9"? Does anybody have a command file already written for this?
 
Find out where your application puts the pid file (something like localhost.pid). Most applications put it in /var or in /usr/local/app/var. Check the config file for your app.

In the cron job, do a kill -9 `cat pidfilenamehere`

Good Luck,
__nether
 
Tks for trying to help.....but I cannot find this PID file anywhere:

[localhost:~] roger% ls /var
/var@
[localhost:~] roger%

[localhost:~] roger% ls /usr/local
bin/ samba/ share/ vscanx/
[localhost:~] roger%

What next to try?
 
This should help:

sudo kill -9 `top -l1 | grep AppName | awk '{print $1}'`

Those ` and ' characters are correct -- you NEED them, so don't forget them. Just remember to replace AppName with part of the name of the app. Then you can add this to the cronjob thing or whatever -- I wouldn't know how to do that, but I'm sure you can find that somewhere in this forum.

NOTE: You may not need the sudo at the start of the command, but I put it there to make sure. However, if you do need sudo, then you'll have to manually put in your password each time, which kind of negates the cronjob thing. If anyone knows how to automatically put in your password each time, I would welcome the suggestion -- and no, I have never been able to get a piped echo command to work.
 
ps -ax | grep BBEdit | grep -v grep | awk '{print $1;}'

this gives you the pid.
The "grep -v grep" is for not returning 2 pids, one correct and one for the "grep BBEdit"
 
Back
Top