将pidof限制为自己的进程

Ste*_*ter 3 bash pid process

在bash,

pidof unison
Run Code Online (Sandbox Code Playgroud)

将列出我所有用户的统一进程.但是我只对在我的uid下开始的实例感兴趣.

我怎样才能做到这一点?

我想做什么:我定期使用unison在几台机器上同步几个帐户.但是,如果当前用户已手动启动unison,我希望同步无法启动.

Eri*_*ouf 6

你可以pgrep改用,比如

pgrep -u <userid> unison
Run Code Online (Sandbox Code Playgroud)

这将返回具有给定用户的euid的协同进程的pid列表.