shell批量yum安装并检查是否安装成功
本脚本使用yum批量安装依赖环境,并检查每个包的安装结果,如果安装失败,则退出安装。类似安装皆可调整后使用
#!/bin/bash # ## packages list packages=( java-1.8.0-openjdk-headless java-1.8.0-openjdk java-1.8.0-openjdk-devel ) for package in "${packages[@]}"; do echo "Installing $package ..." if yum install -y "$package"; then echo "$package Installed" else echo "$package Installation failed, Exited !" exit 1 fi done echo "Java environment installation completed"