Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Killing Access To Devices, Killing processes accessing a device
Corey
post Nov 13 2003, 01:21 PM
Post #1


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 1,254
Joined: 21-September 02
From: St John's, Newfoundland, Canada
Member No.: 3



There have been plenty of times that I have had to search and search the output of "ps aux" to try and find a process that is locking a certain device. More often then not, it had to do with my sound device (/dev/dsp), so, I would issue the command "ps aux" and then manually look at the list of processes to see which ones, from memory, would lock up sound.

Finally a discovered a useful little command to acheive this exact same thing:

QUOTE
$ fuser /dev/dsp
/dev/dsp:  18535 18536 18537 18540 18541 18542


What this program does is that it gives you a list of processes that is currently using a certain device, in this case /dev/dsp .

So, to find out what the program is, just send the output of ps aux to grep:

QUOTE
$ ps aux | grep 18535
duende  18535  0.2  2.3 51644 12296 ?      S    14:45  0:00 xmms


To immediatly kill the process using the device, pass the -k parameter (fuser -k /dev/dsp).

Check out the fuser manpage to learn more.


--------------------
Corey Quilliam
(former) Linuxhelp.ca Administrator
cquilliam-AT-gmail-dot-com

Want to help out Linuxhelp.net? Check out our Linuxhelp Wiki and see if there are some articles you would like to submit!!

--
Ubuntu 8.04 64-bit - Work Laptop (HP-Compaq NC6400 Core2)
Kubuntu 8.04 64-bit - Desktop (HP m8120n QuadCore)
Ubuntu 6.04 - Server (I'm not upgrading this baby until support runs out in 2012) (Some old POS dell)
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
hughesjr
post Nov 15 2003, 11:56 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



This works really well for mounted file systems as well...

If you are trying to unmount a partition and you get the message that it can't unmount, you can use fuser to figure out (then kill) all processes that have items opened on that partition.

Here is an example for a partiton mounted at /mnt/server1/archive ... which is a Windows file server I have mounted via smbfs...

I need to unmount the partition so I can reboot the file server ... so I issue the command:

umount /mnt/server1/archive

and the results are:

umount: /mnt/server1/archive: device is busy

yikes ! - I have something using that share ... and if I don't figure out what it is, I can corrupt the open resource by rebooting....so we can use the fuser command with the -m switch to figure out the processes are using that mount.... the command would be:

QUOTE
fuser -m /mnt/server1/archive


The result is:
/mnt/server1/archive: 9170c

9170 is the process ID ... and the c means that something is using that location as it's current directory (see man fuser for more on what c, e, f, r, and m mean after a PID while using fuser).

The command:

QUOTE
ps -ef | grep 9170

returns this information:

root 9170 9168 0 09:45 pts/1 00:00:00 bash

which means that the user root has the program bash open ... and the c from above means that the program bash's current directory is /mnt/server1/archive. Sure enough, I had a bash terminal window open, and it was setting with /mnt/server1/archive as it's current directory.

After I change the directory to /root in that terminal, the command:

umount /mnt/server1/archive

works great....


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th December 2017 - 09:53 AM