cronのメール送信を止めるcronで設定されているコマンドが実行された場合デフォルトではメールがroot(alias指定してる場合はそのユーザ)に送信される。何度も実行させるものにあたってはcronからのメールが大量になってしまうので、それを止める。 /etc/crontabの編集cronのメールを止めるためには/etc/crontabで設定されているMAILTOという環境変数を修正する。 例 % cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file. # This file also has a username field, that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin #MAILTOの部分を""とする MAILTO="" # m h dom mon dow user command 17 * * * * root run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily 47 6 * * 7 root test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly 52 6 1 * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly MAILTOは環境変数なので/etc/crontabのスケジュールより前に記述する必要がある。 これでもメールが止まらない場合(私はこの段階で解決)私の場合はさっきの手順だけでは止まらなかったので次のファイルも修正した。 Debianで実証(/var/spool/cron/crontabs/rootを編集) % cat /var/spool/cron/crontabs/root #MAITOをこちらにも記述 MAILTO="" # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.1LwC1p/crontab installed on Mon Jan 9 18:46:07 2006) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) #ntpdateで時間補正 0 0 * * * /usr/sbin/ntpdate time-A.timefreq.bldrdoc.gov こちらにも同様の設定を追記したらメールが止まりました。
Counter: 1391,
today: 1,
yesterday: 5
|