Sponsored Content
Top Forums Shell Programming and Scripting Help required on process in unix Post 302229228 by aigles on Tuesday 26th of August 2008 01:08:25 PM
Old 08-26-2008
On an AIX box (not sure for other Unix flavour) , you can also use the fuser command.
Code:
Commands Reference, Volume 2, d - h
fuser Command

Purpose

Identifies processes using a file or file structure.
Syntax

fuser [ -c | -d | -f ] [ -k | -K { SignalNumber | SignalName }] [ -u ] [ -x ] [ -V ]File ...
Description

The fuser command lists the process numbers of local processes that use the local or remote files specified by the File parameter. For block special devices, the command lists the processes that use any file on that device.

Each process number is followed by a letter indicating how the process uses the file:
c 	Uses the file as the current directory.
e 	Uses the file as a program's executable object.
r 	Uses the file as the root directory.
s 	Uses the file as a shared library (or other loadable object).

The process numbers are written to standard output in a line with spaces between process numbers. A new line character is written to standard error after the last output for each file operand. All other output is written to standard error.

The fuser command will not detect processes that have mmap regions where that associated file descriptor has since been closed.
Flags

-c 	Reports on any open files in the file system containing File.
-d 	Implies the use of the -c and -x flags. Reports on any open files which have been unlinked from the file system (deleted from the parent directory). When used in conjunction with the -V flag, it also reports the inode number and size of the deleted file.
-f 	Reports on open instances of File only.
-K SignalNumber | SignalName 	Sends the specified signal to each local process. Only the root user can kill a process of another user. Signal can be specified as either a signal name, such as -9 or KILL for the SIGKILL signal. Valid values for SignalName are those which are displayed by the kill -l command.
-k 	Sends the SIGKILL signal to each local process. Only the root user can kill a process of another user.
Note:
fuser -k or -K might not be able to detect and kill new processes that are created immediately after the program starts to run.
-u 	Provides the login name for local processes in parentheses after the process number.
-V 	Provides verbose output.
-x 	Used in conjunction with -c or -f, reports on executable and loadable objects in addition to the standard fuser output.
Examples

   1. To list the process numbers of local processes using the /etc/passwd file, enter:

      fuser /etc/passwd

   2. To list the process numbers and user login names of processes using the /etc/filesystems file, enter:

      fuser -u /etc/filesystems

   3. To terminate all of the processes using a given file system, enter:

      fuser -k -x -u -c /dev/hd1 

      or

      fuser -kxuc /home

      Either command lists the process number and user name, and then terminates each process that is using the /dev/hd1 (/home) file system. Only the root user can terminate processes that belong to another user. You might want to use this command if you are trying to unmount the /dev/hd1 file system and a process that is accessing the /dev/hd1 file system prevents this.
   4. To list all processes that are using a file which has been deleted from a given file system, enter:

      fuser -d /usr

Files

/dev/kmem 	Used for the system image.
/dev/mem 	Also used for the system image.
Related Information

The kill command, killall command, mount command, and ps command.

For more information about the identification and authentication of users, discretionary access control, the trusted computing base, and auditing, refer to Security.

Jean-Pierre.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX PATH info required PLEASE HELP (I'm new to unix)

I need to know how to enter a unix path in a cgi script for a guest book: example: My URL is http://www.kitachi.info I have an html file in the main folder on my site, the file is called : gbook.html what would the correct unix path for this file be ??? the part of the script... (1 Reply)
Discussion started by: akitachi
1 Replies

2. Programming

UNIX Internals, Help required...

I know UNIX user level commands, shell scripts. But i have no idea about kernel level programming and networking. I know the terms semaphore,IPC,socket programming. But i don't know in details what are these. I need to know the following. 1. Unix kernel level programming. 2. Unix Internals. 3.... (4 Replies)
Discussion started by: digdarshan
4 Replies

3. UNIX for Dummies Questions & Answers

Help Required in Unix Command

Hi All, Can anyone please help me in unix command Query: ==== File contains data along with date and time stamp like, .. Date: 08:23:2005 01:00:00 method: xyz init variables Date 08:23:2005 01:00:01 method: xyz finished init variable .... (2 Replies)
Discussion started by: thaduka
2 Replies

4. HP-UX

urgent help required on changing process priority using nice

Hi folks, Hope you can help me. I have a process that is currently running at nice 20 and need it to run faster (-10?). How do I change the process using nice? I have the process number and thought it would be along the lines of; nice -10 process_id but it doesn't seem to like that. (1 Reply)
Discussion started by: gshuttleworth
1 Replies

5. UNIX for Advanced & Expert Users

Required unix command!!!

Hi, In a file I have data like... -rw-r----- 1 ftpuser users 1036695 Jul 6 14:59 ./APRIL 2007/Ujjain/My Disc (D)/9565DW07.04B -rw-r----- 1 ftpuser users 124080 Jul 6 14:59 ./APRIL 2007/Vadodara/vad_APRIL07/2082DW07.04B The above data is extracted using "find . -name... (12 Replies)
Discussion started by: ronald_brayan
12 Replies

6. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

7. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

8. Shell Programming and Scripting

Unix script required

I have a file 123.txt which is aasaasas=1 bsasasasasa=2 sawqas=3 I want my output to be 1 2 3 I am new to scripting can some1 help me out. (14 Replies)
Discussion started by: karthikkasarla
14 Replies

9. Shell Programming and Scripting

Script to process file from a directory and grep the required content and print

Hi All, below script reads the perticular files from the directory. Am trying to fetch status and print them in the required format. It needs to read line and search for string "Passed/Failed" and print them under correct sub header. script : BASE_DIR=/tmp/test/REPORT/CollectReport #... (16 Replies)
Discussion started by: Optimus81
16 Replies

10. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies
xpamethod(7)							SAORD Documentation						      xpamethod(7)

NAME
XPAMethod - XPA Communication Methods SYNOPSIS
XPA supports both inet and unix (local) socket communication. DESCRIPTION
XPA uses sockets for communication between processes. It supports three methods of socket communication: inet, localhost, and unix. In gen- eral, the same method should be employed for all XPA processes in a session and the global environment variable XPA_METHOD should be used to set up the desired method. By default, the preferred method is "inet", which is appropriate for most users. You can set up a different method by typing something like: setenv XPA_METHOD local # unix csh XPA_METHOD=local; export XPA_METHOD # unix sh, bash, windows/cygwin set XPA_METHOD=localhost # dos/windows The options for XPA_METHOD are: inet, unix (or local), and localhost. On Unix machines, this environment setup command can be placed in your shell init file (.cshrc, .profile, .bashrc, etc.) On Windows platforms, it can be placed in your AUTOEXEC.BAT file (I think!). By default, inet sockets are used by XPA. These are the standard Internet sockets that are used by programs such as Netscape, ftp. etc. Inet sockets utilize the IP address of the given machine and a (usually random) port number to communicate between processes on the same machine or between different machines on the Internet. (Note that XPA has an Access Control mechanism to prevent unauthorized access of XPA access points by other computers on the Net). For users connected to the Internet, this usually is the appropriate communication method. For more information about setting up XPA communication between machines, see Communication Between Machines. In you are using XPA on a machine without an Internet connection, then inet sockets are not appropriate. In fact, an XPA process often will hang for many seconds while waiting for a response from the Domain Name Service (DNS) when using inet sockets. Instead of inet sockets, users on Unix platforms can also use unix sockets (also known as local sockets). These sockets are based on the local file system and do not make use of the DNS. They generally are considered to be faster than inet sockets, but they are not implemented under Windows. Use local sockets as a first resort if you are on a Unix machine that is not connected to the Internet. Users not connected to the Internet also can use localhost sockets. These are also inet-type sockets but the IP address used for the local machine is the localhost address, 0x7F000001, instead of the real IP of the machine. Depending on how sockets are set up for a given plat- form, communication with the DNS usually is not required in this case (though of course, XPA cannot interact with other machines). The localhost method will generally work on both Unix and Windows platforms, but whether the DNS is required or not is subject to individual configurations. A final warning/reminder: if your XPA-enabled server hangs at startup time and your XPA_METHOD is inet, the problem probably is related to an incorrect Internet configuration. This can be confirmed by using the unix method or (usually) the localhost method. You can use these alternate methods if other hosts do not need access to the XPA server. SEE ALSO
See xpa(7) for a list of XPA help pages version 2.1.14 June 7, 2012 xpamethod(7)
All times are GMT -4. The time now is 08:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy