UNIX-скрипт для отправки уведомления по электронной почте, если мы не получили файлы от источника до 12:00, и для отправки предупреждения, если полученные файлы имеют нулевой байт

Это правильно, что касается терминов , так как это касается только связи между терминалом (устройством для отображения символов, объединенным с устройством для ввода символов )и главным компьютером..

Это "включено" может показаться неудобным, но это всего лишь короткий способ сказать "в процессе выполнения ввода" или "в процессе выполнения вывода".

-4
19.09.2019, 16:49
2 ответа

Пробовал со скриптом «Ниже», тоже работало нормально

Пожалуйста, запустите скрипт после 12:00

#!/bin/bash
d=`date +%Y-%m-%d -d "1 days ago"`
#echo $d
echo "Below are list of files present"
find . -maxdepth 1 -type f -iname "*.txt" -newermt $d| sed "s/\.\///g"

count=`find . -maxdepth 1 -type f -iname "*.txt" -newermt $d| sed "s/\.\///g"| wc -l`
if [ $count -eq 9 ]
then
echo "Total Number of file exsists in present directory is $count"
zero_sizefile=`find . -maxdepth 1 -type f -iname "*.txt" -newermt $d -size 0| wc -l`
if [ $zero_sizefile > 0 ]
then
echo "Below are zero sized files"
find . -type f -iname "*.txt" -newermt $d -size 0
else
echo "No files are zero sized files"
fi
else
echo "All files doesnt exists"
fi
-1
28.01.2020, 05:20

Что-то вроде... работает как cronjob?

#!/bin/bash
address="someone@your.company"
basepath=/folder1/folder2/folder3
err=0
expected=9
msg=''
subject='Filecheck'
today=$(date +%Y%m%d)

null_files="$(find ${basepath}/${today} -type f -size 0)"
null_files="$(printf '    %s\n' $null_files )"

count=-1  # '.' counts.  One-off-error :-)
# if there are restricions on the filenames,
# replace this with an appropriate find-command
# and iterate over that instead...
for item in ${basepath}/${today}/* ; do
  ((count++))
done

[[ $count -eq $expected ]] && msg='[ OK ] Count of files as expected\n\n'
[[ $count -gt $expected ]] && \
  msg="[ERROR] Count of files too BIG: ${count}\n\n" ; err=1
[[ $count -lt $expected ]] && \
  msg="[ERROR] Count of files too SMALL: ${count}\n\n" ; err=1

if [[ -n "$null_files" ]]; then
  msg+='[ERROR] Found empty files:\n'
  msg+="$null_files"
  err=1
else
  msg+='[ OK ] No files with with 0 bytes found.'
fi

# echo -e "$msg"

[[ $err -ne 0 ]] && subject="[ERROR] $subject" || subject="[OK] $subject"
sendEmail -t "$address" -u "$subject" -m "$msg"
1
28.01.2020, 05:20

Теги

Похожие вопросы