linux循环程序举例,Shell程序实例集锦一

#!/bin/sh

#server

#################################

#modify by ajian

#function: It is convenient to restart some servers and reduce the wasted time.

#DATE:  2007-7-2

#################################

#路径配置区

APACHEPATH=""

SMB_LOCAL_PATH1=""

SMB_REMOTE_PATH1=""

SMB_LOCAL_PATH2=""

SMB_REMOTE_PATH2=""

#################################

#应用配置区

SMBUSER=""

SMBPASS=""

SMB_UID=

SMB_GID=

#################################

case $1 in

"apache")

if [ $2 = "start" ]

then

echo "starting apache ..."

$APACHEPATH/apachectl start

echo "apache is started."

pidof httpd

elif [ $2 = "stop" ]

then

echo "stopping apache ..."

$APACHEPATH/apachectl stop

echo "apache is stopped."

elif [ $2 = "restart" ]

then

echo "restarting apache ..."

$APACHEPATH/apachectl stop

sleep 5

$APACHEPATH/apachectl start

echo "apache is restarted."

pidof httpd

else

echo "apache's $2 is error."

fi

;;

"smb")

if [ $2 = "remount" ]

then

echo "remounting smbfs..."

umount -f $SMB_LOCAL_PATH1

umount -f $SMB_LOCAL_PATH2

echo "umount is finished."

sleep 5

mount -t smbfs -o username=$SMBUSER,password=$SMBPASS,ui

d=$SMB_UID,gid=$SMB_GID $SMB_REMOTE_PATH1 $SMB_LOCAL_PATH1

mount -t smbfs -o username=$SMBUSER,password=$SMBPASS,ui

d=$SMB_UID,gid=$SMB_GID $SMB_REMOTE_PATH2 $SMB_LOCAL_PATH2

echo "mount is finished."

df -h

elif [ $2 = "mount" ]

then

mount -t smbfs -o username=$SMBUSER,password=$SMBPASS,ui

d=$SMB_UID,gid=$SMB_GID $SMB_REMOTE_PATH1 $SMB_LOCAL_PATH1

mount -t smbfs -o username=$SMBUSER,password=$SMBPASS,ui

d=$SMB_UID,gid=$SMB_GID $SMB_REMOTE_PATH2 $SMB_LOCAL_PATH2

echo "mount is finished."

df -h

else

echo "smb's $2 is error."

fi

;;

"all")

echo "restart apache and remount..."

$APACHEPATH/apachectl stop

sleep 5

umount -f $SMB_LOCAL_PATH1

umount -f $SMB_LOCAL_PATH2

sleep 5

mount -t smbfs -o username=$SMBUSER,password=$SMBPASS,uid=$SMB_U

ID,gid=$SMB_GID $SMB_REMOTE_PATH1 $SMB_LOCAL_PATH1

mount -t smbfs -o username=$SMBUSER,password=$SMBPASS,uid=$SMB_U

ID,gid=$SMB_GID $SMB_REMOTE_PATH2 $SMB_LOCAL_PATH2

echo "mount is finished."

df -h

$APACHEPATH/apachectl start

echo "apache is restarted."

sleep 5

pidof httpd

;;

"status")

if [ $2 = "grather" ]

then

echo "Gather the status of the computer ....."

/movivi/status.sh

echo "Gather is finished."

elif [ $2 = "analyze"  ]

then

echo "analyze the status.ch ......"

/movivi/analyze.sh

cat /movivi/data/sumary.txt

fi

;;

*)

echo "The method of using the script."

echo ""

echo "  server apache stop      means:  关闭apache."

echo "  server apache start     means:  启动apache."

echo "  server apache restart   means:  重启apache."

echo "  server remount            means:  关闭Mount点再挂载."

echo "  server mount              means:  直接挂载Mount点."

echo "  server all                    means:  Include all of above."

echo "  server status gather     means:  收集系统信息."

echo "  server status analyze    means:  分析处理并显示系统信息."

echo "  "

echo ""

;;

esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值