svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm
2013年7月3日 星期三
SVN刪除所有missing的檔案
標籤:
remove,
shell script,
svn
2012年12月18日 星期二
用watch的方式檢查process的存活狀況
while true
do
clear
ps ax | grep -v grep | grep -v $0 | grep tomcat
sleep 5
done
標籤:
alive,
process,
shell script,
watch
2012年11月28日 星期三
重複執行shell command
最近在用bonnie++測試file system的benchmark,等待時間長而且同一個條件要測試許多次,在電腦前面等實在不好,找了重複執行shell command的指令。
首先,修改~/.bashrc
首先,修改~/.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/hdaReference: Always Right
標籤:
repeat,
shell script
2012年7月24日 星期二
使用bash script修改使用者的密碼
sudo useradd test sudo echo "password" | passwd test --stdinReference: stackoverflow
標籤:
password,
shell script
2011年3月10日 星期四
#!/bin/sh
# Author: Norman
ARRAY=( Frank 1.2.3.4 \
Norman 1.2.3.5 )
SYSTEM=`uname -s`
LOG=/tmp/wn_ntpdate.log.$$
i=0
while [ $i -lt 3 ] ; do
NAME=${ARRAY[$i]}
IP=${ARRAY[$i+1]}
echo -n $NAME $IP ' '
case $SYSTEM in
Linux)
ping -c 1 $IP 1> $LOG 2>&1
;;
CYGWIN*)
ping $IP 64 1 1> $LOG 2>&1
;;
*)
exit 1
;;
esac
if [ $? -eq 0 ] ; then
case $SYSTEM in
CYGWIN*)
grep "100.0% packet loss" $LOG 1> /dev/null 2>&1
if [ $? -eq 0 ]; then
echo failed
else
echo ok
scp wn_ntpdate.sh wn_ntpdate.cron test@$IP:/home/test/workspace
echo "Executing ntpdate command..."
ssh test@$IP 'sudo sh /home/test/workspace/wn_ntpdate.sh'
ssh test@$IP 'sudo rm -f /home/test/workspace/wn_ntpdate.sh'
ssh test@$IP 'sudo mv /home/test/workspace/wn_ntpdate.cron /etc/cron.hourly'
echo "#####" [$NAME:$IP] RS Test Environment \(Worker Nodes\) ntpdate Sucess "#####"
echo ""
fi
;;
Linux)
echo ok
scp -q wn_ntpdate.sh wn_ntpdate.cron test@$IP:/home/test/workspace
echo "Executing ntpdate command..."
ssh test@$IP 'sudo sh /home/test/workspace/wn_ntpdate.sh'
ssh test@$IP 'sudo rm -f /home/test/workspace/wn_ntpdate.sh'
ssh test@$IP 'sudo mv /home/test/workspace/wn_ntpdate.cron /etc/cron.hourly'
echo "#####" [$NAME:$IP] RS Test Environment \(Worker Nodes\) ntpdate Sucess "#####"
echo ""
;;
*)
exit 1
;;
esac
else
echo failed.
echo ""
fi
((i++))
((i++))
done
#rm -f $LOG
exit
Reference: Norman
標籤:
cron,
cron.hourly,
linux,
ntpdate,
ping,
shell script
2011年3月6日 星期日
Write a shell script to generate sql
#/bin/sh -x
export ip=3
while [ $ip -le 48 ] ; do
export port=10000
while [ $port -le 10007 ] ; do
echo "insert into compute_node (ip_address, cpu_ghz,\
memory_gbyte, disk_gbyte, status) values ('12.200.83.$ip:$port', \
null, null, null, 'idle');"
((port ++))
done
((ip++))
done
Reference: Frank
標籤:
shell script,
sql
2011年3月1日 星期二
"You must have a tty to run sudo"
# comment out the requiretty config in '/etc/sudoes' #Defaults requirettyReference: bestlong
標籤:
centos,
shell script,
sudo,
tty
2011年2月16日 星期三
Ping hosts using shell script
#!/bin/sh
# Author: Frank
ARRAY=(
${USER1} ${USER1IP}\
${USER2} ${USER2IP})
SYSTEM=`uname -s`
LOG=/tmp/testping.log.$$
i=0
while [ $i -lt 31 ] ; do
NAME=${ARRAY[$i]}
IP=${ARRAY[$i+1]}
echo -n $NAME $IP ' '
case $SYSTEM in
Linux)
ping -c 1 $IP 1> $LOG 2>&1
;;
CYGWIN*)
ping $IP 64 1 1> $LOG 2>&1
;;
*)
exit 1
;;
esac
if [ $? -eq 0 ] ; then
case $SYSTEM in
CYGWIN*)
grep "100.0% packet loss" $LOG 1> /dev/null 2>&1
if [ $? -eq 0 ]; then
echo failed
else
echo ok
fi
;;
Linux)
echo ok
;;
*)
exit 1
;;
esac
else
echo failed.
fi
((i++))
((i++))
done
#rm -f $LOG
exit
Reference: Frank
標籤:
host,
ping,
shell script
Delete "\r" from a shell script
cat foo.sh | tr -d "\r" > foo_noCarrige.shReference: bogdan
標籤:
\r,
remove,
sh,
shell script
訂閱:
文章 (Atom)