用于每天监视文件夹的Shell脚本,如果该文件夹上没有生成新文件,则会发送邮件警报
#!/bin/sh
Value=`find <Dirpath> -type f -daystart -ctime 0 -print | wc -l`
if [ $Value -gt 0 ]; then
echo "File got generated"
else
echo "File not generated Sending mail"
echo "<Messages>" | mail -s "<Subject of mail>" <Mail_ID>
fi
答案 0 :(得分:0)
试试这段代码:
for f in $PATHTOFOLDER/*; do
if [[ ! -e "$f" ]]; then
echo '*** empty folder *************************************'
fi