Change name of cronjob scripts.
This commit is contained in:
parent
4bce06332e
commit
903576a1bd
5 changed files with 0 additions and 0 deletions
31
cronjob-warn-smtp-queue
Executable file
31
cronjob-warn-smtp-queue
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Source the mail configuration.
|
||||
source /etc/mail.conf "mail-queue" 2>/dev/null || {
|
||||
printf "%s: %s\\n" "${0##*/}" "Failed to source /etc/mail.conf" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Don't do anything unless 'mailq' is installed.
|
||||
hash mailq 2>/dev/null && {
|
||||
# Prevent a race with other cron jobs that produce emails.
|
||||
sleep $(( RANDOM % 180 ))
|
||||
|
||||
# Get the queue
|
||||
TMP_OUTPUT="$(mailq)"
|
||||
|
||||
[[ -z "$TMP_OUTPUT" ]] && exit 0
|
||||
|
||||
# Send the message.
|
||||
if [[ -n "${EMAIL_TO[*]}" ]]; then
|
||||
mailx "${MAILX_ARGS[@]}" -S "from=$EMAIL_FROM" -s "Mail queue" "${EMAIL_TO[@]}" <<<"$TMP_OUTPUT" 2>/dev/null || {
|
||||
printf "%s: %s\\n" "${0##*/}" "mailx command failed" >&2
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue