linux获取当前pts
作者:互联网
获取当前pts
[root@192_168_1_165 ~]# echo $SSH_TTY
/dev/pts/3
[root@192_168_1_165 ~]# env | grep pts
SSH_TTY=/dev/pts/3
检测指定pts的运行程序
[root@192_168_1_165 luting]# ps -ef | grep tailf | grep -v grep | grep pts/3
root 15683 13858 0 14:17 pts/3 00:00:00 tailf test1.py
检测当前pts运行程序 ps -ef | grep tailf | grep -v grep | grep pts/`echo $SSH_TTY | awk -F'/' '{print $4}'` 杀死指定pts
检测当前pts运行程序 ps -ef | grep tailf | grep -v grep | grep pts/`echo $SSH_TTY | awk -F'/' '{print $4}'` 杀死指定pts
ps -ef | grep tailf | grep -v grep | grep pts/3 | xargs kill -9
标签:tailf,grep,pts,ef,192,获取,linux,root 来源: https://www.cnblogs.com/lutt/p/15808875.html