这个是基础啊..... 刚学别想一下子整个都写出来, 先将自己知道的一条一条命令写下来,然后在整体的连接上去. 不知道在论坛搜搜 有很多资源的作者: hundanclark 时间: 2011-05-27 21:01
检测httpd状态:
#!/bin/bash
service httpd status &> /dev/null //查看状态,strat返回的是0,stop返回的是1 。&>输出重
if [ $? -ne 0 ] ; then 定向不在显示器输出
echo "http server is down. at time:`date`" >> /var/log/htmon.log
service httpd restart
service httpd status &> /dev/null
if [ $? -ne 0 ] ; then
chkconfig --level 2345 httpd on
shutdown -r now
fi
fi
myudel.sh脚本用于批量添加用户帐号
#!/bin/bash
read -p "the number of users(1-99):" num
read -p "username prefix is:" pre
read -p "expire time is (YYYY-mm-dd):" etime
read -p "initial password is:" pw
i=1
while [ $i -le $num ]
do
if [ $i -lt 10 ] ; then
un="${pre}0$i"
else
un="${pre}$i"
fi
useradd -e $etime $un
echo $pw | passwd --stdin $un &> /dev/null
let i++
done