zoukankan      html  css  js  c++  java
  • sh, 批量执行Linux命令

    step 1:创建一个sh批处理命令文件 
    # vim /etc/batch_ssh/install_redis.sh


    step 2:给当前用户,能够执行sh脚本权限
    # chmod install_redis.sh 777


    step 3: 编写要批量执行的命令,read表示等待前端用户输入,sleep表示等待时间单位为 秒。

    echo ' begin to install 01 plugin ';
    yum install cpp -y;
    echo ' yum finish install 01 plugin ';
    sleep 3;
     
    echo ' begin to install 02 plugin ';
    yum install binutils -y;
    echo ' yum finish install 02 plugin ';
    sleep 3;
     
    echo ' begin to install 03 plugin ';
    yum install glibc-kernheaders -y;
    echo ' yum finish install 03 plugin ';
    sleep 3;
     
    echo ' begin to install 04 plugin ';
    yum install glibc-common -y;
    echo ' yum finish install 04 plugin ';
    sleep 3;
     
    echo ' begin to install 05 plugin ';
    yum install glibc-devel -y;
    echo ' yum finish install 05 plugin ';
    sleep 3;
     
    echo ' begin to install 06 plugin ';
    yum install gcc -y;
    echo ' yum finish install 06 plugin ';
    sleep 3;
     
    echo ' begin to install 07 plugin ';
    yum install make -y;
    echo ' yum finish install 07 plugin ';
    sleep 3;
     
    echo 'all plugin had installed completed';
    read;


    step 4: 最后,记得保存文件 

    # :wq install_redis.sh


    step 5: 执行批量脚本文件install_redis.sh
    # /etc/batch_ssh/install_redis.sh
    或者在当前目录,则执行
    # ./install_redis.sh

    图片

    当所有命令,后台执行完毕后,提示信息如下:

    图片

  • 相关阅读:
    Quartz.net 定时任务在IIS中未按时执行
    扩展方法
    mysql 实用语句
    jquery each map
    js匿名函数多时注意
    ASP.NET MVC3调用分部视图
    eclipse快捷键
    regular 点滴
    适配器模式
    php代码实现简单图片下载
  • 原文地址:https://www.cnblogs.com/itshare/p/6517236.html
Copyright © 2011-2022 走看看