要求:
检查当前日期/ a / b / DROP和/ a / b / ARCHIVE目录中是否存在* .idx文件的脚本。(DONE)
如果/ a / b / DROP缺少* .idx文件,则从/ a / b / ARCHIVE复制* .idx文件以获取当前日期。(一天只有1个文件)
需要将脚本的输出发送到几个邮件ID。
#!/bin/bash
# Checking DROP ZIP file for current date
#***************************************
filestr=`find /a/b/DROP -name "*.idx" -mtime -1 -print`
if [ "$filestr" = "" ]; then
echo "DROP ZIP File missing for `date +%D`"
else
echo "DROP ZIP file exists for `date +%D`"
fi
#Checking ARCHIVE IDX file for current date
#******************************************
filestr=`find /a/b/ARCHIVE -name "*.idx" -mtime -1 -print`
if [ "$filestr" = "" ]; then
echo "ARCHIVE IDX File missing for `date +%D`"
else
echo "ARCHIVE IDX file exists for `date +%D`"
fi
有人可以帮助我实现第二个第三要求吗?
答案 0 :(得分:1)
#!/bin/bash
# req.sh
filestr=`find /a/b/DROP -name "*.idx" -mtime -1 -print`
if [ "$filestr" = "" ]; then
missing="1"
echo "DROP ZIP File missing for `date +%D`"
else
echo "DROP ZIP file exists for `date +%D`"
fi
filestr=`find /a/b/ARCHIVE -name "*.idx" -mtime -1 -print`
if [ "$filestr" = "" ]; then
echo "ARCHIVE IDX File missing for `date +%D`"
elif [ "$missing" = "1" ];then
echo "Copying from ARCHIVE `date +%D`"
cp $filestr /a/b/DROP
else
echo "ARCHIVE IDX file exists for `date +%D`"
fi
以
运行脚本sh req.sh |/usr/sbin/sendmail -r sender@domain.tld recipient1@domain.tld