Linux Shell脚本每天监视文件夹,如果该文件夹上未生成新文件,将发送邮件警报

Linux Shell脚本每天监视文件夹,如果该文件夹上未生成新文件,将发送邮件警报,linux,shell,ubuntu,unix,automation,Linux,Shell,Ubuntu,Unix,Automation,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 "<Me

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
#/垃圾箱/垃圾箱
Value=`find-type f-daystart-ctime 0-print | wc-l`
如果[$Value-gt 0];然后
echo“已生成文件”
其他的
回显“发送邮件时未生成文件”
回显“|邮件-s”
fi
尝试以下代码:

for f in $PATHTOFOLDER/*; do
  if [[ ! -e "$f" ]]; then
    echo '*** empty folder *************************************'          
 fi

你检查过incrond(inotify cron守护进程)吗?没有,上面的代码是为我编写的。谢谢你。你打算解释一下吗?你应该在回答中加入一些解释、研究或其他细节。访问了解更多信息