編寫Linux腳本
編寫Linux腳本
#。/bin;pid=`ps ;-ef|grep ;tomcat|grep ;-v ;grep|awk ;';{print ;$2}';`。if ;[ ;";$pid"; ;= ;";"; ;] ; ;then。 ; ; ; ;echo ;";tomcat ;service ;does ;not ;start。"。else; ; ; ; ;kill ;-9 ;$pid。
導讀#。/bin;pid=`ps ;-ef|grep ;tomcat|grep ;-v ;grep|awk ;';{print ;$2}';`。if ;[ ;";$pid"; ;= ;";"; ;] ; ;then。 ; ; ; ;echo ;";tomcat ;service ;does ;not ;start。"。else; ; ; ; ;kill ;-9 ;$pid。
?以下是重啟Linux下某進程的shell腳本,以tomcat進程為例:#!/binpid=`ps?-ef|grep?tomcat|grep?-v?grep|awk?'{print?$2}'`if?[?"$pid"?=?""?]?;?then????echo?"tomcat?service?does?not?start!"else????kill?-9?$pid????pid1=`ps?-ef|grep?tomcat|grep?-v?grep|awk?'{print?$2}'`????if?[?"$pid1"?=?""?]?;?then????????echo?"Successfully?kill?tomcat?processes:?"?$pid????else????????echo?"tomcat?kill?process?Failed!"????????exit?1????fifirm?-rf?/opt/tomcat/work/*./startup.shpid2=`ps?-ef|grep?tomcat|grep?-v?grep|awk?'{print?$2}'`if?[?"$pid2"?=?""?]?;?then???echo?"tomcat?service?Failed?to?start!"else???echo?"tomcat?service?starts?successfully:"?$pid2fi?本文來自系統大全為您提供如需轉載請注明!推薦win10下載
編寫Linux腳本
#。/bin;pid=`ps ;-ef|grep ;tomcat|grep ;-v ;grep|awk ;';{print ;$2}';`。if ;[ ;";$pid"; ;= ;";"; ;] ; ;then。 ; ; ; ;echo ;";tomcat ;service ;does ;not ;start。"。else; ; ; ; ;kill ;-9 ;$pid。
為你推薦