赞
踩
[root@rocky8 ~]# cat backup.sh
#!/bin/bash
#
#**********************************************************************************************
#Author: Raymond
#QQ: 88563128
#Date: 2021-10-09
#FileName: backup.sh
#URL: raymond.blog.csdn.net
#Description: The test script
#Copyright (C): 2021 All rights reserved
#*********************************************************************************************
COLOR='\E[1;31m'
COLOR_END='\E[0m'
SRC=/etc
DEST=/backup
echo -e ${COLOR}Starting backup...${COLOR_END}
sleep 2
cp -av $SRC $SRC$DEST`date +%F_%H-%M-%S`
echo -e ${COLOR}Backup is finished${COLOR_END}
[root@rocky8 ~]# cat systeminfo.sh
#!/bin/bash
#
#**********************************************************************************************
#Author: Raymond
#QQ: 88563128
#Date: 2021-10-09
#FileName: systeminfo.sh
#URL: raymond.blog.csdn.net
#Description: The test script
#Copyright (C): 2021 All rights reserved
#*********************************************************************************************
RANDOM_COLOR="\E[1;"$[RANDOM%7+31]"m"
GREEN="echo -e \E[1;32m"
COLOR_END="\E[0m"
ETHNAME=`ifconfig |head -1| tr -s ":" " "|cut -d" " -f 1`
$GREEN----------------------Host systeminfo--------------------$COLOR_END
echo -e "HOSTNAME: $RANDOM_COLOR`hostname`$COLOR_END"
echo -e "IPADDR: $RANDOM_COLOR` ifconfig $ETHNAME|grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' |head -n1`$COLOR_END"
#echo -e "IPADDR: $RANDOM_COLOR` hostname -I`$COLOR_END"
echo -e "OSVERSION: $RANDOM_COLOR`cat /etc/redhat-release`$COLOR_END"
echo -e "KERNEL: $RANDOM_COLOR`uname -r`$COLOR_END"
echo -e "CPU: $RANDOM_COLOR`lscpu|grep '^Model name'|tr -s ' '|cut -d : -f2`$COLOR_END"
echo -e "MEMORY: $RANDOM_COLOR`free -h|grep Mem|tr -s ' ' : |cut -d : -f2`$COLOR_END"
echo -e "DISK: $RANDOM_COLOR`lsblk |grep '^sd' |tr -s ' ' |cut -d " " -f4`$COLOR_END"
$GREEN---------------------------------------------------------$COLOR_END
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。