Summary of common shell commands

 

ps -ef|grep Dflag=${APP_NAME}|grep -v grep|grep -v tail|awk 'BEGIN{printf "kill "}{printf "%s ", $2}'|bash
echo "${APP_NAME} stopped!"

 illustrate:

 ps -ef [Get the currently active process]

 grep abc [contains the string abc]

 grep -v abc [does not contain the string abc]

 ps -ef|grep Dflag=${APP_NAME}|grep -v grep|grep -v tail [Filter values ​​with the string "Dflag=xxx" in all active processes without "grep" and without " tail”]

 awk 'BEGIN {printf "kill "} {printf "%s ", $2}'|bash [print kill + process number [the second column in the list displayed by ps -ef is the process number] For example, if the process number is 11891, it will Output kill 11891 The last line of the command |bash means to execute kill 11891, that is to kill the process, if you do not write |bash, it will only print and not execute]

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326279979&siteId=291194637