60秒ごとにファイルを見つけたいです。その期間内にファイルが存在する場合は、電子メールをトリガーする必要があります。以下で試しましたが、うまくいきません。ご協力ありがとうございます!事前にありがとう
#!/bin/sh
cd /my/path
while true
do
set Hrs = `date "+H"`
if [ $Hrs >= 17 ] && [$Hrs <=23 ]; then
$filefound = `ls tt.txt`
if [ $filefound = "tt.txt" ]; then
mailx send email......
fi
fi
sleep 5
done
ベストアンサー1
以下のコードを試してください。
#!/bin/sh
cd /my/path
while true; do
Hrs=`date "+%H"`
if [ "$Hrs" -ge 17 ] && [ "$Hrs" -le 23 ]; then
if [ -f tt.txt ]; then
echo "File Found" | mail -s "This is the subject" <email address>
fi
fi
sleep 60
done
メール部分を除くスクリプト全体をテストしました。他はすべて大丈夫でメールも大丈夫だったらと思います。乾杯。