希望能得到一些建议或指导。我不太熟悉这些东西,但已经设法导航,测试和检查到这一点。一次解决一个错误!
运行Plesk 11.0.9时,我试图设置一个简单的Cron作业,运行一个shell脚本来检测即将满的邮箱,这样我或用户就可以得到通知并解决问题。
以根用户身份运行脚本,前提是这将检查所有邮箱。
这个脚本来自Plesk论坛(上一篇文章http://forum.parallels.com/showthread.php?106635-Qmail-e-mail-quota-notification-script-for-Plesk-9-3-10),在那里许多用户似乎已经成功运行了这个作业,但是我得到了这个错误
/usr/local/psa/bin/mboxfull.sh:第26行:bc:未找到命令
/usr/local/psa/bin/mboxfull.sh:第32行:bc:未找到命令
这似乎是一个非常普遍的“写什么就不行”错误,所以我的搜索没有给我多少方向,如何纠正这个问题。
下面的完整脚本,标有“冒犯”行。任何指路的帮助都将不胜感激!
#! /bin/bash
# Mail quota reaching it's limit e-mail notification
# script for Plesk 9.3+ / Plesk 10 & Qmail
# Modified by "Scy" from the original script
# provided by "azur99" in Plesk forum:
# http://forum.parallels.com/showthread.php?t=71666
#setenv QMAILUSER 'do-not-reply'
MAILROOT=/var/qmail/mailnames
cd $MAILROOT > /dev/null
for DIR in *.*;do
cd $MAILROOT/$DIR
for MAILBOX in * ;do
if [ -d $MAILBOX ]
then
# look for specific mailbox quota file and set mailbox softquota
QUOTAFILE=$MAILROOT/$DIR/$MAILBOX/Maildir/maildirsize
# Fetching mailbox quota size in bytes
HARDQUOTA=$((`head -1 $QUOTAFILE | cut -d S -f1`))
if [ "$HARDQUOTA" -eq 0 ]; then
continue
fi
# Fetching space used by mailbox in bytes
(THIS IS LINE 26!) MBOXSPACE=$((`tail -n +2 $QUOTAFILE | cut -c1-12 | paste -sd+|bc`))
# Calculate the quota limit required for mail warning (85% for default)
SOFTQUOTA=$((10 * $HARDQUOTA / 100))
# Calculate mailbox usage percentage (with two decimals)
(THIS IS LINE 32) MBOXPERCENT=$(echo "scale=2; $MBOXSPACE*100/$HARDQUOTA" | bc)
# Check if the mailbox is full enough for warning, and if, send the warning mail
if [ $HARDQUOTA -gt 0 -a $MBOXSPACE -gt $SOFTQUOTA ]; then
# Let's generate the values in megabytes (with two decimals)
HARDQUOTA=$(echo "scale=2; $HARDQUOTA/1048576" | bc)
if [ "$(echo $HARDQUOTA | cut -c1)" = "." ] ; then HARDQUOTA="0"$HARDQUOTA
fi
MBOXSPACE=$(echo "scale=2; $MBOXSPACE/1048576" | bc)
if [ "$(echo $MBOXSPACE | cut -c1)" = "." ] ; then MBOXSPACE="0"$MBOXSPACE
fi
/usr/sbin/sendmail -t << EOF
To: $MAILBOX@$DIR
From: ******@*******.com
Bcc: ****@******.com
Subject: Your mailbox is almost full
Dear mail user,
Your e-mail $MAILBOX@$DIR is about to reach its maximum quota. You are using $MBOXSPACE MB ($MBOXPERCENT%) out of the maximum quota $HARDQUOTA MB.
We would kindly suggest you to delete some older messages and purge them to free some space in the mailbox. If the quota limit is reached, you won't be able to receive any new messages and the sender will receive 'mail quota exceeded' notifications.
Another option is to configure your POP3 mail client (e.g. Microsoft Outlook, Mozilla Thunderbird or Apple Mail) to delete the messages on the server mailbox every time the mail account is read.
This is an automated message, do not reply. If you require any assistance, please open a support ticket at http://*******/support.php .
EOF
fi
fi
done;
done;
最佳答案
line 26: bc: command not found
意味着您的服务器上没有安装“bc”实用程序。
尝试通过以下命令安装:
# yum install bc
或者对于类似debian的系统:
# apt-get install bc
关于linux - 在Plesk 11的ShellScript Cron作业中找不到命令错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23439252/