Changes between Version 1 and Version 2 of waue/2009/0707
- Timestamp:
- Jul 7, 2009, 3:00:44 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
waue/2009/0707
v1 v2 7 7 #!/bin/bash 8 8 9 #str=$(ps axw -eo pid,command | grep "org.apache.catalina.startup.Bootstrap" | grep "start" | awk '{print $1}') 10 9 # 把全部apache且start的pid放到變數$str內,若apache的pid 為1011 1012 1013,則$str=1011 1012 1013 11 10 str=$(ps axw -eo pid,command |\ 12 11 grep "apache" | grep "start" |\ 13 12 awk '{print $1}') 14 echo "str = $str"15 13 14 # 雖然kill 支援一次刪除多個檔,如kill -9 1011 1012 1013,但若想要砍一個就喊一下的話,就要用到for...in的應用 16 15 count=1 17 16 for i in $str … … 19 18 echo "string[$count]= $i" 20 19 echo "kill -9 $i" 20 # 注意shell裡的運算要用$((n+n)),而$(...)的用法與`...`相同 21 21 count=$(($count+1)) 22 22 23 done 23 24