shell獲取tomcat程序號實現必殺
一臺伺服器跑N多tomcat例項,根據例項名稱在apache-tomcat-7.0.56/的目錄下,看下shell指令碼,如查詢apache-tomcat-7.0.56的專案,也可以具體細化:
ps -ef | grep apache-tomcat | grep -v grep | awk '{print $2}'
- 1
這個指令碼首先用ps -ef | grep apache-tomcat 獲得了程序資訊中包含 apache-tomcat 的程序資訊,這樣出來的結果中會包含grep本身,所以我們需要用 | grep -v grep 來排除grep本身,然後通過 awk ‘{print $2}’來打印出要找的程序。
上述例子中只是將程序id號打印出來,當然也可以修改為將tomcat程序kill掉,如下指令碼:
ps -ef | grep apache-tomcat | grep -v grep | awk '{print $2}' | sed -e "s/^/kill -9 /g" | sh -
- 1
版權宣告:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/u012599988/article/details/44060387
相關推薦
shell獲取tomcat程序號實現必殺
一臺伺服器跑N多tomcat例項,根據例項名稱在apache-tomcat-7.0.56/的目錄下,看下shell指令碼,如查詢apache-tomcat-7.0.56的專案,也可以具體細化: ps -ef | grep apache-tomcat | grep -v grep | awk '{
在專案啟動時(無request)獲取Tomcat埠號
上一篇說的將非Spring Boot專案註冊到Eureka Server並提供服務也說到,配置檔案裡eureka.port必須要與本機tomcat埠號相同,但不同環境往往有不同的tomcat埠號,以往我使用不同環境的配置檔案以確保eureka服務埠與tomcat
通過指令碼的方式殺tomcat程序(shell指令碼),shell中將一個檔案的內容讀出賦值給一個變數
#!/bin/bash echo "==================stop tomcat=========================" ps -aux | grep /usr/local/
Linux下Tomcat埠號以及程序相關命令
1. 檢視tomcat程序 ps -aux | grep tomcat (或者ps -ef | grep tomcat都行) [plain] view plain copy root  
spark實現獲取上個月1號及最後一天
最近在分析的時候要分析周及月的資料 那麼月的話 一開始我是直接獲取當月的1號及最後一天 但是後來發現數據不太對 因為這個樣子跑的話 會存在最後一天資料丟失(和本身的資料有關) 所以這裡就要寫 獲取上個月的1號及最後一天 有不對的請指正: import java.t
linux根據程序號PID查詢啟動程式的全路徑(程式實現根據PID程序號得到程序名字或根據程序名字取得程序號)
sam9x25-linux login: root Password: [email protected]:~ cd app [email protected]:~/app ps PID TTY TIME CMD 749 tt
shell 獲取時間及如果應用程序不存在時啟動
#! /bin/bash curdate="`date +%Y-%m-%d,%H:%M:%S`"; echo $curdate; log="/home/wwwroot/rundeck/start.log"; stillRunning=$(ps -ef |grep "rundeck-l
用shell指令碼獲取svn版本號,作為專案的小版本號
在進行自動部署的時候,經常需要用指令碼獲取程式的最新版本號 在xcode中選中target的 Build Phases , 在Editor 中 選擇 Add Build Phases --> Add Run Script Build Phases 然後新增前提是
在shell中獲取其他程序的pid
今天接到一個小任務,寫一個指令碼,來檢測linux系統中某個程序的的狀態。那麼,首先要獲取該程序的pid, 折騰了一下,發現可以通過 命令 ps |grep 來獲取 具體程式碼如下: #!/bin/
Shell判斷子程序(pid)狀態實現動態迴圈
[root@zhangwan2 xingcheng]# cat get_data_1.sh.20171101 #!/bin/bash #Date:2017/7/29 #Author: create b
java獲取當前tomcat程序(linux)
在某些時候我們需要取得tomcat程序號,然後通過程序號處理一些其他事務。那麼在web專案中,如何通過某些方法取得當前tomcat伺服器的pid?首先,我們知道我們可以使用exec()方法執行linux命令。那麼我們就可以有這樣一個思路: 通
linux命令(26):Bash Shell 獲取程序 PID
Linux 的互動式 Shell 與 Shell 指令碼存在一定的差異,主要是由於後者存在一個獨立的執行程序,因此在獲取程序 pid 上二者也有所區別。 互動式 Bash Shell 獲取程序 pid 在已知程序名(name)的前提下,互動式 Shell 獲取程序 pid
iOS應用程式之如何獲取版本號實現應用更新
{ resultCount = 1; results = ( { artistId = 301724683; artistName = Citibank; artistViewUrl = "http://itunes.apple.com/us/artist/citibank/id3017246
Windows中 命令列 查詢程序號 殺程序
win7命令列 端口占用 查詢程序號 殺程序: 1.cmd 中. 2.根據埠號查程式的程序號:netstat -ano |findstr 埠號; 3.根據程式的程序號檢視具體的程式名稱:tasklist|findstr 程序號 4.強制、遞迴 刪除本程式及其子程序:tas
shell獲取執行超過1天時間的程序
#!/bin/bash sys_uptime=$(cat /proc/uptime | cut -d" " -f1); user_hz=$(getconf CLK_TCK) ; for pid in `
mac下 殺tomcat程序
eclipse異常關閉了,重新開啟,然後啟動tomcat,居然報tomcat的埠被佔用 沒事,找到被關閉的程序,kill掉就ok了 ps -el | grep java 1697 ?? 2:33.12 /System/Library/Java/Ja
linux shell 獲取程序id,或者在應用程式中獲取程序id
1、linux shell下獲取程序ID的方法: ps -A |grep "/usr/sbin/gps_app"| awk '{if($6 == "'start'") {print $1}}' pidof "cmdname" pgrep "cmdname" 這三種
bash shell獲取程序的pid
前幾天在寫一個指令碼時在獲取程序的pid時出現了一點點意外,當時的情境大概是這樣的:跑一個任務A,然後任務B要監控A的狀態,一旦A結束,B也要結束。當初第一反應就是獲取B的pid然後判斷A是否在執行,如果沒有則kill掉B。可是當初就是不成功(用的是 $!)
微信公眾號實現掃碼獲取微信用戶信息(網頁授權)
erro 掃描二維碼 傳值 commit intval host apps 圖片 vendor 剛開始接觸微信的時候一頭霧水,領導想要一個掃碼獲取微信用戶信息的功能,而且是掃的別人的二維碼,我是一陣忙活啊。 經過努力和嘗試,終於功夫不負有心人啊,趕緊記錄一下,我用的是th
用Redis輕松實現秒殺系統
tar 幫助 說過 腳本 .net 所有 paxos 你會 用戶 秒殺系統的架構設計 秒殺系統,是典型的短時大量突發訪問類問題。對這類問題,有三種優化性能的思路: 寫入內存而不是寫入硬盤 異步處理而不是同步處理 分布式處理 用上這三招,不論秒殺時負載多大,都能輕松應對。