shell検出redis状態および関数例
2544 ワード
redis , , redis
#! /bin/bash
## redis
a=`ps aux|grep redis |awk '{print $1}'|grep redis`
if [ -z $a ];then
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
fi
, ( /dev/sdb) ; , ; ( , dd if=/dev/zeroof=/dev/sdb bs=512 count=1 , ; , 67 ; , 100M, 1G; , 68 ; , ext3; , 69 ; , 0 ;
2、 ; , ;
#! /bin/bash
function disk() {
read -p "Input the device you want to format. " dev
read -p "Waring! It will be format the device $dev, and the data on$dev will be deleted, are you sure to do this? Y/N " k
while :; do
if [ $k == 'N' -o $k == 'n' ]; then
exit
elif [ $k == 'Y' -o $k == 'y' ]; then
dd if=/dev/zero of=$dev bs=512 count=1
n1=`echo $?`
if [ $n1 -ne 0 ]; then
return 67
else
echo -e "n
p
1
1
+100M
n
p
2
+1G
w
quit
"|fdisk $dev
fi
n2=`echo $?`
if [ $n2 -ne 0 ]; then
return 68
else
mkfs.ext3 /dev/sdb1 && mkfs.ext3 /dev/sdb2
fi
n3=`echo $?`
if [ $n3 == 0 ]; then
return 0
else
return 69
fi
else
continue
fi
done
}
disk
n4=`echo $?`
if [ $n4 == 67 ]; then
echo "Delete the partition table error."
elif [ $n4 == 68 ]; then
echo "Reinstall the partition table error."
elif [ $n4 == 69 ]; then
echo "Format the patition error."
else
echo "The whole opration is successful!"
fi