用于其他网络主机的 w 命令

用于其他网络主机的 w 命令

虽然该who命令引用本地计算机,但rwho显示的信息相同全部本地网络的已知主机。

同样,w显示有关本地计算机上的用户及其进程的信息。是否有w等效的rwho,它显示相同的信息,但相对于所有其他主机?

答案1

解决方法使用GNU并行

parallel --nonall --sshloginfile .cluster --tag w

就我而言,我使用一个 file .cluster,其中包含我想要运行命令的主机名:

$ cat .cluster
n04
n05
n06

我的输出

n04  11:19:43 up 110 days, 20:54,  2 users,  load average: 0.16, 0.24, 0.25
n04 USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
n04 userB    pts/0    172.29.38.50     Wed15    5days  8.39s  0.08s -bash
n04 userA    pts/1    172.29.38.7      11:19    0.00s  0.00s  0.00s bash -c eval `e
n05  11:20:03 up 110 days, 19:49, 18 users,  load average: 0.10, 0.03, 0.01
n05 USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
n05 userD pts/0    :13.0            06Aug14 61days  0.00s  0.00s /bin/sh /var/tm
n05 userA    pts/1    172.29.38.7      Mon08   26:35m  0.15s  0.15s -bash
n05 userA    pts/2    172.29.38.7      11:20    0.00s  0.02s  0.00s bash -c eval `e
n05 userA    pts/14   :pts/39:S.6      30Sep14  5days  4:02   2:29  SCREEN -S heli
n05 userA    pts/20   :pts/39:S.3      30Sep14  5days  2.21s  2.21s /bin/bash
n05 userA    pts/21   :pts/39:S.2      30Sep14  5days  2.60s  2.60s /bin/bash
n05 userA    pts/22   :pts/39:S.1      30Sep14 25days  3.11s  3.11s /bin/bash
n05 userA    pts/18   :pts/39:S.4      30Sep14  1:45m  4.20s  4.20s /bin/bash
n05 userA    pts/29   :pts/39:S.0      30Sep14  6days  0.69s  0.69s /bin/bash
n05 userA    pts/36   :pts/39:S.8      30Sep14  5days  2.39s  2.39s /bin/bash
n05 userA    pts/37   :pts/39:S.9      30Sep14  5days  3.40s  3.40s /bin/bash
n05 userA    pts/39   172.29.38.7      17Sep14  1:45m  1.34s  1.10s screen -xr heli
n05 userC pts/40   :12.0            11Sep14 26days  0.00s  0.00s /bin/sh /var/tm
n05 userA    pts/16   :pts/39:S.5      30Sep14  5days 15:50  28.30s bash -lhimvBH
n05 userA    pts/42   :pts/39:S.7      30Sep14 25days  1.52s  1.52s /bin/bash
n05 userA    pts/45   :pts/39:S.10     30Sep14  5days  4.72s  4.72s /bin/bash
n05 userA    pts/46   :pts/39:S.11     30Sep14  5days  0.32s  0.32s /bin/bash
n05 userD pts/41   :11.0            17Sep14 19days  0.00s  0.00s /bin/sh /var/tm
n06  11:19:59 up 110 days, 19:49,  3 users,  load average: 0.00, 0.00, 0.00
n06 USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
n06 userA    pts/0    172.29.38.7      11:19    0.00s  0.02s  0.00s bash -c eval `e
n06 userD pts/1    :14.0            12Aug14 55days  0.00s  0.00s /bin/sh /var/tm
n06 userD pts/2    :14.0            12Aug14 55days  0.00s  0.00s /bin/sh /var/tm

相关内容