Changes between Version 1 and Version 2 of waue/2009/0707


Ignore:
Timestamp:
Jul 7, 2009, 3:00:44 PM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2009/0707

    v1 v2  
    77#!/bin/bash
    88
    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
    1110str=$(ps axw -eo pid,command |\
    1211 grep "apache" | grep "start" |\
    1312 awk '{print $1}')
    14 echo "str = $str"
    1513
     14# 雖然kill 支援一次刪除多個檔,如kill -9 1011 1012 1013,但若想要砍一個就喊一下的話,就要用到for...in的應用
    1615count=1
    1716for i in $str
     
    1918 echo "string[$count]= $i"
    2019 echo "kill -9 $i"
     20 # 注意shell裡的運算要用$((n+n)),而$(...)的用法與`...`相同
    2121 count=$(($count+1))
     22 
    2223done
    2324