INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Problem with fuser within shell Scripts.

Problem with fuser within shell Scripts.

(OP)
Folks,

it's driving me crazy again !!!

Following problem:

We're using Shell Scripts to start/stop applications on our servers.
Some of them include unmounting several filesystems as well.

Now, there are some systems where - after shutting down the application - several processes remain active, preventing us from doing an umount.

The idea was to simply use

CODE

fuser -ck /name_of_filesystem 

However this is not working. No matter how often we repeat the command within the script.

But (!) if I enter the commands

CODE

fuser -ck /name_of_filesystem
umount /name_of_filesystem 

directly over the command line everything is fine.

Any idea what's wrong here ?

Another approach was to fetch the PIDs from

CODE

fuser -cv /name_of_filesystem 

and then do something like

CODE

kill -9 $PIDs 

but the output is extremely weird and I haven't been able to grab the PIDs from it ...

Regards,
Thomas

RE: Problem with fuser within shell Scripts.

(OP)
Crontab winky smile

RE: Problem with fuser within shell Scripts.

Crontab
???

RE: Problem with fuser within shell Scripts.

(OP)
If not crontab I think the directory is /root/ ...

RE: Problem with fuser within shell Scripts.

(OP)
/root/ it is ...

RE: Problem with fuser within shell Scripts.

(OP)
Here's the problem:

CODE

fuser -cv /fs 

CODE

USER        PID ACCESS COMMAND
/fs:                 me          462 F.ce. cat
                     me          493 F.ce. ls
                     me         1913 F.ce. smb 

To get rid of the /fs: at the beginning i tried

CODE

fuser -cv /fs | cut -c22- 

That's where it started to become weird because the output looked like this:

CODE

462 493 1913 

Something similar happens when I try

CODE

fuser -cv /fs > /tmp/test.txt 

Here I get the following on the screen:

CODE

USER        PID ACCESS COMMAND
/fs:                 me        F.ce. cat
                     me        F.ce. ls
                     me        F.ce. smb 

And the content of /tmp/test.txt contains only

CODE

462 493 1913 

Regards,
Thomas

RE: Problem with fuser within shell Scripts.

I asked for the output of fuser -c /fs (NO v option)

RE: Problem with fuser within shell Scripts.

(OP)
That's

CODE

/fs:    462ce 493ce 1913ce 

RE: Problem with fuser within shell Scripts.

The odd thing about the fuser command is that some of the output line goes to stdout and some goes to stderr. That's what's causing the confusion. You can get just the PIDs by filtering out stderr. This would do it...

CODE

kill -9 `fuser /fs 2>/dev/null` 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close