一些小腳本

多目錄的建立 #!/bin/bash mkdir /root/userdata echo "userdata create success" for ((i=1; i<=50; i=i+1)) do mkdir "/root/userdata/user$i" chmod 754 "/root/userdata/user$i" echo "user$i create success" done 最小系統初始化程序 #set ulimit echo "ulimit -SHn 102400">> /etc/rc.localbash

for i in ls /etc/rc3.d/S* do curser=echo $i|cut -c 15- echo $curserdom

case $curser in crond | irqbalance | microcode_ctl|network|random|sshd|syslog|local) echo "base serverice,Skip!" ;; *) echo "change $curser to off" chkconfig --level 235 $curser off service $curser stop ;; esac done echo "service is init is ok............." 文件備份 #!/bin/bash bak=ls /root|grep bak if [ -z "$bak" ];then mkdir /root/bak fi cd /root/bak yy=date +%C%y mm=date +%m dd=date +%d tar zcvf "$yy$mm$dd_etc.tar.gz" /etc 用戶添加 #!/bin/bash nu=30 for ((i=1; i<=$nu; i=i+1)) do if [ $i -ge 10 ];then echo $i userdel std$i #useradd -G class1 "std$i" #echo 12345|passwd --stdin "std$i" else echo 0$i userdel std0$i #useradd -G class1 "std0$i" #echo 12345|passwd --stdin "std0$i" fi done echo "任務完成" lvs腳本 #!/bin/bash TEST_VIP= TEST_RIP1= TEST_RIP2=ssh

. /etc/rc.d/init.d/functions logger $0 called with $1code

case "$1" in start) #set vip /sbin/ipvsadm --set 30 5 6 /sbin/ifconfig eth0:0 $TEST_VIP broadcast $TEST_VIP netmask 255.255.255.255 broadcast $TEST_VIP up /sbin/route add -host $TEST_VIP dev eth0:0 /sbin/ipvsadm -A -t $TEST_VIP:80 -s wrr /sbin/ipvsadm -a -t $TEST_VIP:80 -r $TEST_RIP1:80 -g -w 2 /sbin/ipvsadm -a -t $TEST_VIP:80 -r $TEST_RIP2:80 -g -w 1 touch /var/lock/subsys/ipvsadm > /dev/null 2>&1server

相關文章
相關標籤/搜索