---
title: "linux 下批量操作web服务"
author: "gaozhonghui"
date: "2012-06-12T14:00:47Z"
tags: []
categories: ["编程语言"]
slug: "linux-web"
draft: false
lastmod: "2012-06-12T14:00:47Z"
id: 1559060
url: "https://toptree.iteye.com/blog/1559060"
---

服务器上的应用很多，一个一个的操作，太麻烦。
  写脚本批量start 、stop 、restart
  

```python

#!/bin/bash
#############################################
# Scripts for rotating catalina daily
# at 2012-06-07
#############################################

workPath=$1
cmd=$2

if [ -z ${workpath} ];then
   echo "参数异常"
   exit
fi

if [ -z ${cmd} ];then
   echo "请输入参数 start stop restart"
   exit
fi


for appPath in ${workPath}*;do

    if [ "stop" = ${cmd} ]||[ "restart" = ${cmd} ]
    then
        ${appPath}/bin/shutdown.sh
        echo "shudown ${cmd} "
    fi

    sleep 3

    if [ "start" = ${cmd} ]||[ "restart" = ${cmd} ]
    then
       ${appPath}/bin/startup.sh
       echo "startUp ${cmd}"
    fi
done

```