今天在自己电脑上搭建了个server,同学(貌似量还比较大)访问了下,电脑有点超负荷,linux阿,有点小受不了,索性kill apache2,I call i服了 you!真多^_^
ps:一个小教训,以前写了脚本后,有的时候懒得chmod +x,总是sh scriptname.sh,今天发现都不对,整了半天,原来是要bash scriptname.sh,默认是shell貌似不是bash
想想写了个脚本,有点小成就写在这里
#!/bin/bash
#kill_process.sh
current_PID=$$
echo $current_PID
ps aux | grep "apache2" | grep -v "grep" | awk '{print $2}' > /tmp/${current_PID}.txt
while read -r pid
do
{
echo "Kill -9 $pid"
kill -9 $pid
}
done < /tmp/${current_PID}.txt
#rm -f /tmp/${current_PID}.txt
只复制目录结构而不复制文档,很有用的,对我自己
#!/bin/bash
#cpdir.sh
process_id=$$
usage()
{
echo "Usage: ./cpdir.sh source_dir dest_src"
}
#判断输入
if [ $# -ne 2 ]
then
{
usage
echo "input error"
exit
}
fi
srcdir=$1
destdir=$2
#判断源与目的目录是不是目录
if [ ! -d $srcdir ]
then
{
usage
echo "${srcdir} is not a dir\n"
exit
}
fi
if [ ! -d $destdir ]
then
{
usage
echo "${dest} is not a dir\n"
exit
}
fi
#讲源目录结构cp到tmp file
find ${srcdir}/* -type d > /tmp/srcdir_tmp_${process_id}.txt
sed -n "s/^${srcdir}/${destdir}/p" /tmp/srcdir_tmp_${process_id}.txt > /tmp/srcdir_${process_id}.txt
rm -rf ${destdir}/*
while read line
do
{
mkdir $line
}
done < /tmp/srcdir_${process_id}.txt
find ${destdir}/* -type d > /tmp/destdir_${process_id}.txt
diff /tmp/srcdir_${process_id}.txt /tmp/destdir_${process_id}.txt
rm -f /tmp/*.txt
阅读(1392) | 评论(0) | 转发(0) |