2012年11月28日 星期三

重複執行shell command

最近在用bonnie++測試file system的benchmark,等待時間長而且同一個條件要測試許多次,在電腦前面等實在不好,找了重複執行shell command的指令。

首先,修改~/.bashrc
vim ~/.bashrc
加入:
repeat() {
    n=$1
    shift
    while [ $(( n -= 1 )) -ge 0 ]
    do
        "$@"
    done
}
讀bash環境設定
source ~/.bashrc
如此一來就可以重複執行shell command了! 下列指令會重複執行3次
repeat 3  bonnie++ -u root -d /dev/hda
Reference: Always Right

沒有留言:

張貼留言