Linux 中/var/spool/postfix/maildrop目錄下堆積大量小文件

1,原理分析:
經過調查,是因爲linux在執行cron時,會將cron執行腳本中的output和warning信息,都會以郵件的形式發送Cron全部者, 而因爲客戶環境中的sendmail和postfix沒有正常運行,致使郵件發送不成功,所有小文件堆積在了maildrop目錄下面,並且沒有自動清理轉換的機制,因此長達一年的時間,此目錄已堆積了大量的文件。查看man cron的信息,能夠知道會發送給cron owner.

[root@mw1 postfix]# man cron linux

DESCRIPTION post

Cron searches /var/spool/cron for crontab files which are named after accounts in crontabs found are loaded into memory. Cron also searches for /etc/crontab and the spa

files in the directory, which are in a different format (see crontab(5) ). Cron then wakes up every minute, examining all stored crontabs, checking each command to see orm

if it should be run in the current minute. When executing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment crontab

variable in the crontab, if such exists). it


(注意:若是sendmail或者postfix正常運行,則會在/var/mail目錄下產生大量的郵件,也會堆積) form


2, 解決方案: 原理

在cron的第一行加入 MAILTO=""即可,這樣執行當前用戶的Cron時,不會發送郵件。 file

Please add the MAILTO="" in the head of cron , please see the blow sample. command

[root@mw1 postfix]# crontab -e

MAILTO=""

*/5 * * * * /opt/OCMonitor/bin//ocSysMonitor -top -sar –netfmt

相關文章
相關標籤/搜索