一,bash脚本
#!/bin/bash
# ===================backup base========================
# rpm va log backup 的路径
back_base=/storage/logs/rpmvalogs
if [ ! -d ${back_base} ];then
mkdir -p ${back_base}
fi
# ===================backup path========================
date_year=$(date +"%Y")
date_month=$(date +"%m")
back_path=${back_base}/${date_year}_${date_month}
echo ${back_path}
# ===================mkdir back_path========================
if [ -d ${back_path} ];then
echo ${back_path}目录已经存在,不能重复创建
else
mkdir -p ${back_path}
fi
# ===================run and log========================
file_date=$(date +"%Y%m%d")
echo ${file_date}
rpm -Va > ${back_path}/rpmva_${file_date}.log
二,说明:
这个脚本很简单,就是按年月创建目录,把每天做rpm -Va的结果保存到创建的目录中,
日志文件按天命名,
这是我们工作中用到的一个脚本,供大家参考
标签:Va,back,base,date,path,rpm,bash From: https://www.cnblogs.com/architectforest/p/18470358