lsof and have to find file, pid


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users lsof and have to find file, pid
# 1  
Old 02-20-2009
Java lsof and have to find file, pid

Hi All,

My target is to find the biggest files opened by any process and from that i have to find process id and the corresponding file also.

To get the process id which is accessing the biggest file in the given file system, i am using the below command.

pid=`lsof -s /home/arun/my_work | awk '{print $7,$2}'| sort -n | tail -1 | awk '{print $2}'`

with the above process id, Now i have to get the file name with complete path.
How can i achieve this? [with find command or whatever]


PID is "1425492", and now i want to find the exact file which is bigger in size and also it is opened by the process id. But when i tried your option i am getting the output as below,

myserv123>lsof -fb -p 1425492
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sas 1425492 ampsys cwd VDIR 46,42001 0 4043309312 /home/usr/SAS/IntTech (/dev/vx/dsk/)
sas 1425492 ampsys 0r VCHR 2,2 0t0 16628 /dev/null
sas 1425492 ampsys 1w FIFO 0xf1000100b2a35eb0 0
sas 1425492 ampsys 2w FIFO 0xf1000100b2a35eb0 0
sas 1425492 ampsys 3u IPv4 0xf10002000cabc398 0t0 TCP *:* (CLOSED)
sas 1425492 ampsys 5u unix 0xf10002000cbc7008 0t0 ->0xf10002000142c408
sas 1425492 rampsys 8u unix 0xf10002000ce2d808 0t0 ->0xf10002000d809008


It is giving many lines and i cannot see the exact file which is bigger in the file system..

My Problem and target is:
Have to find the biggest file or fastly growing file in the file system and from that take the process id and the file name (with complete path). Then my action is to send a mail to corresponding user and have to kill the process by process id and have to remove the file (bigger or growing one which belongs to the process id).

Please help me.
Thanks for your help.

# 2  
Old 02-20-2009
Do you have users using EnterpriseGuide?
# 3  
Old 02-22-2009
Java

yeah.
we are using EG.

Help me out to make this works.
# 4  
Old 02-23-2009
If you have EG users, there is a config file somewhere ( I cant remember at the moment but when have more time, will have a look...) to specify the "working" storage unfortunately the default for these account isnt the the work in sasv9.cfg file...whatvever they do finishes when not configured in ~/sasuser.v91 of their home directories and what happens is whereas in unix sas sessions ending SAS cleans up the temp working files, you know the big sorting files etc .sas7bdat... the ones generated by EG in the home directory seems to have been forgotten...
What exactly is your issue? or what are you after?
# 5  
Old 02-23-2009
Java

Hi vbe,
Thanks for your information about EG.
My issue here is,
when a file system is getting rid of some processes which is growing some files. Step we take is kill that process and remove the file from fils system.

For this i want to know,the process id - which keep updating some data to the file(bigger file) (by lsof command). Next i have to find the file name and its path - i dont know how to get this.

Please help me out.
Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find the corresponding command for a existing PID?

Hi All, A process completed already and I have the PID. I want to know the which command used for this PID. 'ps' command and '/proc' folder having the list current process only. Is there a way to search completed process PID? Thanks, Manimuthu (5 Replies)
Discussion started by: k_manimuthu
5 Replies

2. UNIX for Advanced & Expert Users

Find PID using a Port?

Hi, I do not have root user credentials nor do I have the functional id of the process that uses port 80. How can I find the pid of the process using the port number 80 ? Operating System: Linux (6 Replies)
Discussion started by: mohtashims
6 Replies

3. HP-UX

Find port for Pid

Hi, Is this the most appropriate way of finding the listen port number given the pid is "16659" ? lsof -Pan -i tcp -i udp | grep 16659 | grep -i "listen"If so, how can I extract "7001" and assign it to a variable say myport=7001 from the below output which happens to be actual port number? ... (1 Reply)
Discussion started by: mohtashims
1 Replies

4. UNIX for Dummies Questions & Answers

Find PID for a port

Hi, I need to find the PID for a given port on the below system. HP-UX mymachine B.11.31 U ia64 3223107173 unlimited-user license How can I ? (4 Replies)
Discussion started by: mohtashims
4 Replies

5. Shell Programming and Scripting

Find PID for a process

I want to kill a process run by a user of another group. How do I do that..? (3 Replies)
Discussion started by: Haimanti
3 Replies

6. Shell Programming and Scripting

Find and lsof

Hi All, My target is to find the biggest files opened by any process and from that i have to find process id and the corresponding file also. To get the process id which is accessing the biggest file in the given file system, i am using the below command. lsof -s /home/arun/my_work |... (3 Replies)
Discussion started by: Arunprasad
3 Replies

7. Shell Programming and Scripting

How to link lsof and find cmd?

Hi All, My target is to find the biggest files opened by any process and from that i have to find process id and the corresponding file also to avoid file system being hung-up. Finding the process id: is to kill the process Finding the biggest file: is to remove the file To get the process... (0 Replies)
Discussion started by: Arunprasad
0 Replies

8. Shell Programming and Scripting

how to find only PID value

When I run ps -aef | grep aaa.exe it gives out put user 5091 5518 0 10:13:25 pts/1 0:00 grep aaa.exe user 4647 2479 0 09:26:31 ? 0:25 /kk/zzz/user/xxx/bin/aaa.exe user1 1111 2222 0 08:26:31 ? 0:25 /kk/zzz/user1/xxx/bin/aaa.exe I need Only PID value ie... (5 Replies)
Discussion started by: madhusmita
5 Replies

9. UNIX for Advanced & Expert Users

Find PID's

I have a script which spawns multiple compilations. Sometimes due to some errors i have to terminate that script. Now comes the main part, how do I do that? I can see the individual compilations via ps -ef | grep compiler and also kill them via kill -9 pid But the scirpt continues: ... (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

10. UNIX for Dummies Questions & Answers

How to find a hanging pid

I am trying to write a simple shell script to find a hanging pid and kill it.Any idea how to find a hanging pid?? (6 Replies)
Discussion started by: Ravi Kanth
6 Replies
Login or Register to Ask a Question