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