Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, First of all actually I want to find out the working directory of a process. This can be easily found by Code: pwdx pid But to find the pid ...
  1. #1
    Just Joined!
    Join Date
    Jun 2009
    Posts
    2

    How to find user only process for a spesific program

    Hi,

    First of all actually I want to find out the working directory of a process. This can be easily found by

    Code:
    pwdx pid
    But to find the pid of the process I have to always check it out via ps. Now i make some research and i found this piece bash code:

    Code:
    echo COMMAND | xargs -ixxx ps -C xxx -o pid= | xargs -ixxx ls -l /proc/xxx/cwd
    It shows directly the working directory of the process. But now the problem comes, if there is other users who are using this command i get the error:

    4531: Permission denied

    This is caused because other users are also running the same process.

    Now here comes the question, how can i modify the above code that it shows only process from a specific user( in other words the working directory)

    Thanks in advance

  2. #2
    Just Joined!
    Join Date
    Jun 2009
    Posts
    2
    Ok i found another way, i've used awk and for loop, this code do the same job

    Code:
    for pid in $(ps -u USERNAME  | grep PROGRAMNAME | awk '{print $1;}'); do pwdx $pid ; done

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...