Plesk 12 versucht, eine Mail mit Warteschlangendetails abzurufen

401
user1616338

Ich versuche, eine E-Mail einzurichten, die mir sagt, wenn 100 E-Mails in der E-Mail-Warteschlange sind. Ich bin kein Linux-Server, also schätze ich @ @ d etwas Hilfe. Ich habe:

 # 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 

Was ich in einem plesk Forum gefunden habe.

Wenn ich den Cron-Job betreibe, heißt es

 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. 

Irgendwelche Ideen bitte?

bearbeiten ...

Ich habe den Benutzer auf root umgestellt und es werden nun E-Mails gesendet, aber die anderen Fehler bleiben bestehen. Ich kann die Größe der E-Mail-Warteschlange nicht feststellen

1

1 Antwort auf die Frage

0
Oleg Neumyvakin

Versuchen Sie diese Version:

#!/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 

Achten Sie darauf, dass es wirklich schwierig ist, einen guten tragbaren Bash / SH / cmd-Code zu erstellen. IMO, es ist besser, Go zu verwenden und übersichtliche, portable Programme für jedes Betriebssystem zu erstellen.