首页 > 代码库 > sh, 批量执行Linux命令
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 ‘\n begin to install 01 plugin \n‘;
yum install cpp -y;
echo ‘\n yum finish install 01 plugin \n‘;
sleep 3;
echo ‘\n begin to install 02 plugin \n‘;
yum install binutils -y;
echo ‘\n yum finish install 02 plugin \n‘;
sleep 3;
echo ‘\n begin to install 03 plugin \n‘;
yum install glibc-kernheaders -y;
echo ‘\n yum finish install 03 plugin \n‘;
sleep 3;
echo ‘\n begin to install 04 plugin \n‘;
yum install glibc-common -y;
echo ‘\n yum finish install 04 plugin \n‘;
sleep 3;
echo ‘\n begin to install 05 plugin \n‘;
yum install glibc-devel -y;
echo ‘\n yum finish install 05 plugin \n‘;
sleep 3;
echo ‘\n begin to install 06 plugin \n‘;
yum install gcc -y;
echo ‘\n yum finish install 06 plugin \n‘;
sleep 3;
echo ‘\n begin to install 07 plugin \n‘;
yum install make -y;
echo ‘\n yum finish install 07 plugin \n‘;
sleep 3;
echo ‘all plugin had installed completed‘;
read;
step 4: 最后,记得保存文件
step 4: 最后,记得保存文件
# :wq install_redis.sh
step 5: 执行批量脚本文件install_redis.sh
# /etc/batch_ssh/install_redis.sh
或者在当前目录,则执行
# ./install_redis.sh
当所有命令,后台执行完毕后,提示信息如下:
sh, 批量执行Linux命令
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。