欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux "ps -ef|grep" 简写为pg 博客分类: linux linux

程序员文章站 2024-03-17 22:21:58
...

1. 执行命令创建pg文件

sudo vi /usr/local/bin/pg

    文件内容

#!/bin/bash
ps -ef|grep $1

 2. 设置权限

sudo chmod 755 /usr/local/bin/pg

 

完毕!

 

测试一下语句"pg zookeeper":

hadoop@rick-ubuntu:~$ pg zookeeper
hadoop   24231     1  0 14:08 tty2     00:00:01 /usr/lib/jvm/java-8-oracle/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /home/hadoop/work/zookeeper/bin/../build/classes:/home/hadoop/work/zookeeper/bin/../build/lib/*.jar:/home/hadoop/work/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/hadoop/work/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/hadoop/work/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/home/hadoop/work/zookeeper/bin/../lib/log4j-1.2.16.jar:/home/hadoop/work/zookeeper/bin/../lib/jline-0.9.94.jar:/home/hadoop/work/zookeeper/bin/../zookeeper-3.4.6.jar:/home/hadoop/work/zookeeper/bin/../src/java/lib/*.jar:/home/hadoop/work/zookeeper/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /home/hadoop/work/zookeeper/bin/../conf/zoo.cfg
hadoop   27572 26009  0 14:24 pts/0    00:00:00 /bin/bash /usr/local/bin/pg zookeeper
hadoop   27574 27572  0 14:24 pts/0    00:00:00 grep zookeeper

 

 同样的方法, 可以创建k9(kill -9) 和tf(tail -f)命令

相关标签: linux