- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to use lsof to find files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2014 02:03 AM
04-19-2014 02:03 AM
Re: how to use lsof to find files
>Would it be possible to have help on a script that would kill all the output of the lsof command?
This will select the PIDs:
UNIX95=EXTENDED_PS ps -H -f -p $(lsof +aL1 /var | awk '
BEGIN {
Large_file = 1000000 # min size to flag
Regular_file = "REG"
pid_list = ""
getline # eat header
}
$8 == 0 && $5 == Regular_file && $7 >= Large_file {
if (pid_list == "")
pid_list = $2
else
pid_list = pid_list "," $2
}
END {
print pid_list
}')
Kill them:
kill $(lsof +aL1 /var | awk '
BEGIN {
large_file = 1000000 # min size to flag
regular_file = "REG"
pid_list = ""
getline # eat header
}
$8 == 0 && $5 == regular_file && $7 >= large_file {
if (pid_list == "")
pid_list = $2
else
pid_list = pid_list " " $2
}
END {
print pid_list
}')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2014 12:14 PM
04-19-2014 12:14 PM
Re: how to use lsof to find files
Thank you , as you said "dangerous", I am a bit reluctant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2014 12:35 PM
04-19-2014 12:35 PM
Re: how to use lsof to find files
all the processes seen by "ps" are the same script (crontab entry)
mcelrate[390]/ #UNIX95=EXTENDED_PS ps -H -f -p 7121,7122,7127,7142 ps: error on write ps: error on write UID PID PPID C STIME TTY TIME CMD ora10g 7142 11688 0 Sep 13 ? 25:44 /usr/bin/sh /data8/oradata/files/rms/cronFTP_1830.ksh ora10g 7122 21593 0 Sep 13 ? 25:42 /usr/bin/sh /data8/oradata/files/rms/cronFTP_1830.ksh ora10g 7121 1 0 Sep 27 ? 00:00 sh -c /data8/oradata/files/rms/cronFTP_1830.ksh ora10g 7127 7121 0 Sep 27 ? 00:00 /usr/bin/sh /data8/oradata/files/rms/cronFTP_1830.ksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2014 09:20 PM
04-19-2014 09:20 PM
Re: how to use lsof to find files
>as you said "dangerous", I am a bit reluctant.
Dangerous in that if you don't review the output from the first, you might kill too many with the second.
You could put a check on the USER column.
>all the processes seen by "ps" are the same script (crontab entry)
These are all old. One tree has been orphaned.
Can you add these PIDs to the list to run under ps: 11688 21593
- « Previous
-
- 1
- 2
- Next »