ひとり勉強ログ

ITエンジニアの勉強したことメモ

【crontab】CentOS7.1で crontab 設定後のメールを止める方法

crontabの設定後、コマンド実行のたびにメールが配信される。 都度メールが配信されてもウザいのでメール配信を止める。

1.crontab 設定ファイルを編集

設定ファイル「/etc/crontab」を確認。

[bash] [root@localhost ~]# cat /etc/crontab [/bash]

[bash] SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root

For details see man 4 crontabs

Example of job definition:

.---------------- minute (0 - 59)

| .------------- hour (0 - 23)

| | .---------- day of month (1 - 31)

| | | .------- month (1 - 12) OR jan,feb,mar,apr ...

| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

| | | | |

* * * * * user-name command to be executed

[/bash]

3行目の「MAILTO=root」となっている部分を「MAILTO=」に変更する。

■変更前 [bash] MAILTO=root [/bash]

■変更後 [bash] MAILTO= [/bash]

2.crontab を再起動する

[bash] [root@localhost ~]# systemctl restart crond [/bash]