Search code examples
bashprocesspid

restrict pidof to own processes


In bash,

pidof unison

will list me unison processes of all users. However I am only interested in instances started under my uid.

How can I achieve this?

What I want to do: I'm periodically syncing several accounts on several machines using unison. However, I want the sync to not start, if the current user has manually started unison.


Solution

  • You could use pgrep instead, like

    pgrep -u <userid> unison
    

    which will return a list of pids of unison processes that have the euid of the given user.