- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- help with ksh fuser kill script
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
Forums
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
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
10-17-2003 01:13 AM
10-17-2003 01:13 AM
#
Occasionally they fail because the file system is busy. We have an "fuser -kcu" section that kills processes in the script, but I want to know the name of the process involved (because it should already be gone).
#
Can someone help me get it out of this file, please?
#
fuser -kcu $DIR 1>file1 2>file2
#
"file1" looks like this. It could have one entry in one line or 40 entries in 4 lines. It fills a line with PIDs and then moves to the next line. There are a variable number of spaces between PIDs, depending on the length of the PID, and how many fill a line. (There are 4 spaces between PIDs in this example. The ITRC Forum web page condenses spaces.) I can't figure out how to get a single PID in a variable all by itself one at a time:
#
# cat file1
#
13751 14052 14061 13735 13898 13742 13747 13745 13755 13836 13731 13737 13765 13775 14042 13767 13769 13771 13773 13779 13777 13847 13855 13856 13859 13861 13870 13871 13890 13886 13888 13901 14056 13740
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2003 01:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2003 01:24 AM
10-17-2003 01:24 AM
Re: help with ksh fuser kill script
I would suggest that you run "fuser -cu $DIR 1> file1 2> file2" (without the kill) first .
Then use the suggested loop in the last response.
Then redo your current fuser command.
Or
do the fuser without kill then do the ps script, but after the ps and before the done add : kill -SIGKILL $pid
Best regards,
Kent M. Ostby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2003 01:26 AM
10-17-2003 01:26 AM
Re: help with ksh fuser kill script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2003 02:05 AM
10-17-2003 02:05 AM
Re: help with ksh fuser kill script
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2003 02:39 AM
10-17-2003 02:39 AM
Re: help with ksh fuser kill script
#
So, we don't care what happens to it. We only shut down Oracle to make it easy to unmount the disks. I could just kill -9 everything. I just don't want to hang anything and force a reboot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2003 03:39 AM
10-17-2003 03:39 AM
Re: help with ksh fuser kill script
I would suggest -15 or -18 first then -9...
-9 will disregard any children and abandon them...when it kills the named process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2003 11:35 AM
10-17-2003 11:35 AM
Re: help with ksh fuser kill script
I prefer avoiding temp files by using arrays, but they are limited in length.
set -A dirs /dir1 /dir2 /dir3
set -A pids $(fuser -c ${dirs[@]})
# tell me about all the processes
ps -fp "${pids[@]}"
# better yet, use lsof!
lsof -nPp "$(echo ${pids[@]} | sed -e 's/ /,/g')
# terminate them as gracefully as possible
kill -TERM ${pids[@]}
If you want to iterate a long list of processes, then this may help.
fuser -c ${dirs[@]} | while read pids
do
for pid in $pids
do
ps -fp $pid
kill -TERM $pid
done
done
I do hope some of this helps.