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.
pidof command is used to find out the process IDs of a specific running program. It is basically an identification number that is automatically assigned to each process when it is created.
To filter the top output to a specific process, press the O key and enter the entry as COMMAND=name, where the name refers to the process name. Press ENTER, and the top utility will filter the processes to systemd only. You can also highlight the specific process while keeping other processes in view.
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.
You can parse ps
output like this:
ps -ef | grep unison | grep -v grep | grep "${USER}" | awk '{print $2}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With