Plesk 12 пытается получить почту с подробностями очереди

294
user1616338

Я пытаюсь настроить почту, которая сообщит мне, когда в почтовой очереди 100 писем. Я не специалист по Linux, поэтому буду признателен за помощь. Я имею:

 # get server hostname hostname=`cat /etc/hostname`  current_mailq= "/var/qmail/bin/qmail-qstat"  # `postqueue -p | tail -n 1 | cut -d' ' -f5`  yourEmail="xxxx@gmail.com"   if [ "$current_mailq" -gt "100" ] then echo "Mail queue problem - there is currently $current_mailq mails in queue. Please check it out." > check_email_queue_outgoing.txt mail -s "$hostname - mail queue alert - there are $current_mailq emails in queue" "$yourEmail" < check_email_queue_outgoing.txt else echo "Mail queue is fine - there is currently $current_mailq mails in queue. Please check it out." echo "Do nothing, situation is fine." fi 

Который я нашел на форуме plesk.

Когда я запускаю работу cron, она говорит

 Output from command /home/xxxxxx/check_email_queue.sh ..  /home/xxxxxx/check_email_queue.sh: line 2:  : command not found /home/xxxxxx/check_email_queue.sh: line 3:  : command not found cat: /etc/hostname: No such file or directory /home/xxxxxx/check_email_queue.sh: line 6:  : command not found /home/xxxxxx/check_email_queue.sh: line 7: /var/qmail/bin/qmail-qstat : No such file or directory /home/xxxxxx/check_email_queue.sh: line 8:  : command not found /home/xxxxxx/check_email_queue.sh: line 10:  : command not found /home/xxxxxx/check_email_queue.sh: line 12:  : command not found /home/xxxxxx/check_email_queue.sh: line 13:  : command not found /home/xxxxxx/check_email_queue.sh: line 21: syntax error near unexpected token `fi' /home/xxxxxx/check_email_queue.sh: line 21: `fi' Mail handler 'limit-out' said: REPLY:554:5.7.0 Your message could not be sent. The user xxxxxx is not allowed to send email. 

Есть идеи, пожалуйста?

редактировать ...

Я переключил пользователя на root, и теперь он отправляет почту, но другие ошибки остаются - я не могу узнать размер почтовой очереди, спасибо

1

1 ответ на вопрос

0
Oleg Neumyvakin

Попробуйте эту версию:

#!/bin/bash  hostname=`cat /etc/hostname`  current_mailq="`postqueue -p | tail -n 1 | cut -d' ' -f5`" yourEmail="xxxx@gmail.com"  echo "$current_mailq"  if (( "$current_mailq" >= "100" )) ; then echo "Mail queue problem - there is currently $current_mailq mails in queue. Please check it out." > check_email_queue_outgoing.txt mail -s "$hostname - mail queue alert - there are $current_mailq emails in queue" "$yourEmail" < check_email_queue_outgoing.txt else echo "Mail queue is fine - there is currently $current_mailq mails in queue. Please check it out." echo "Do nothing, situation is fine." fi 

Обратите внимание, что действительно трудно создать хороший переносимый код bash / sh / cmd. ИМО, лучше взять язык Go и создавать понятные переносимые программы для любой ОС.

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