可以将该脚本加入到开机自启动里面,这样开机就会输出基本信息
!/bin/bash
info(){
system=$(hostnamectl | grep System | awk '{print $3}')
kernel_release=$(hostnamectl | grep Kernel | awk -F : '{print $2}')
Virtualization=$(hostnamectl | grep Virtualization | awk '{print $2}')
server_name=$(hostname)
ipaddr=$(hostname -I)
echo "当前系统版本是:${system}"
echo "当前系统内核是:${kernel_release}"
echo "当前虚拟平台是:${Virtualization}"
echo "当前主机名是:${server_name}"
echo "当前ip地址:${ipaddr}"
}
checkerrror(){
error_info=$(dmesg | grep error)
if [ -e ${error_info} ]
then
echo "无错误日志!"
else
ehcho ${error_info}
fi
}
info
checkerrror