System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Identify processes launched from a directory

viacava_1
Advisor

Identify processes launched from a directory

Hello,

I am writing a script that kills processes that were launched from a directory or a sub-directory of it.
I need to identify the processes to be killed.
I am doing that on machines with HP-UX 11.x. I know that lsof could help me but I am not sure it is installed on every machine.
Is there another way to do that ?

Thanks to any help
Jose
6 REPLIES
mobidyc
Trusted Contributor

Re: Identify processes launched from a directory

Hello

Maybe with fuser ?
but lsof would be a better choice.

regards,
Cedrick Gaillard
Best regards, Cedrick Gaillard
Kenan Erdey
Honored Contributor

Re: Identify processes launched from a directory

Hi,

ps -efx shows full command names. you can grep from the output.
Computers have lots of memory but no imagination
viacava_1
Advisor

Re: Identify processes launched from a directory

Thanks Mobidyc.
I know fuser but I can't see how to use it for my problem. Fuser list processes using a file but not processes launched from a known directory.

Jose
viacava_1
Advisor

Re: Identify processes launched from a directory

Thanks Kenan.
Ps -efx is ok if processes are launched with full pathnames.
But how to deal with people doing that :
cd toto; ./truc

Jose
mobidyc
Trusted Contributor

Re: Identify processes launched from a directory

Hi,

you could identify executable commands in the directory and fuser them:
fuser -u /usr/sbin/fuser
/usr/sbin/fuser: 6976t(root)

a little bit ugly but it will work.

Regards,
Cerick Gaillard
Best regards, Cedrick Gaillard
viacava_1
Advisor

Re: Identify processes launched from a directory

Thanks Mobidyc,

Yes, a bit ugly but it should work.
I'll do that.

Many thanks
Jose