执行效果如下:
[root@centos218 ~]#jcmdp
9137: /u06/etsuser/confluent-3.1.1/bin
io.confluent.support.metrics.SupportedKafka
9096: /u06/etsuser/confluent-3.1.1/bin
org.apache.zookeeper.server.quorum.QuorumPeerMain
9336: /u06/etsuser/confluent-3.1.1/bin
io.confluent.kafkarest.KafkaRestMain
9215: /u06/etsuser/confluent-3.1.1/bin
io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain
[root@centos218 ~]#
首先编写脚本:/etc/rc.d/init.d/jcmdp
#!/bin/bash
# Which jcmd to use
if [ -z "$JAVA_HOME" ]; then
JCMD="jcmd"
else
JCMD="$JAVA_HOME/bin/jcmd"
fi
$JCMD |grep -v sun | awk '{print ""; system("pwdx "$1); print $2}'
然后在用户目录编辑: vim ~/.bash_profile
增加
alias jcmdp=/etc/rc.d/init.d/jcmdp
最后执行source ~/.bash_profile 或退出会话,重新连接
即可。
其实也就是jcmd和pwdx两个命令的合集。
-----------------------------------------------------
@ do one thing, do it better