LoginSignup
4
3

More than 5 years have passed since last update.

crontabにおけるMAILFROM

Last updated at Posted at 2016-09-05

結論

  • RHEL/CentOS 6・7では使える
  • Ubuntu 16.04 LTS / Debian Jessie では使えない
  • 他のOSでは適宜cron実装とman crontabもしくはman 5 crontabで確認する

詳細

送信元メールアドレスを指定できるという機能で、ググると出てくることがある。

例: http://linux.die.net/man/5/crontab (2016-09-05時点)

If MAILFROM is defined (and non-empty), it will be used as the envelope sender address, otherwise, ''root'' will be used.

(本当にrootなのか各ユーザからなのかは知らん)

ただ、自環境で使おうとして使えないということが多かった。

まずcron (crontab) と言っても千差万別。極端な安全寄りにはIEEE Std 1003.1あたりのcron仕様に準拠するもの以外は使えると見込めない、といった議論になるが、それだと概ね自分の環境で使えることが多いMAILTOもないため退行し過ぎという印象。

現実的にどこが分岐点かというと、Vixie cronと呼ばれる実装の4.1あたりのようだ。
Vixie cronは4.1でISC Cronとリネームされ、この4.1をベースにRHEL/CentOS系列 (Fedoraからだろうと思うが) 2007年に cronieというフォークを使うようになった。
上述のdie.netも「crontab - tables for driving cron (ISC Cron V4.1)」とある

With the advent of the GNU Project and Linux, new crons appeared. The most prevalent of these is the Vixie cron, originally coded by Paul Vixie in 1987. Version 3 of Vixie cron was released in late 1993. Version 4.1 was renamed to ISC Cron and was released in January 2004. Version 3, with some minor bugfixes, is used in most distributions of Linux and BSDs.

In 2007, Red Hat forked vixie-cron 4.1 to the cronie project and included anacron 2.3 in 2009.

(https://en.wikipedia.org/wiki/Cron)

ここで「自分の環境で使えない」理由はこの一文「Version 3, with some minor bugfixes, is used in most distributions of Linux and BSDs.」にある。
Vixie cron 3系を維持しているDebian/Ubuntu系統ではMAILFROMは存在しない。
Debianではsidレベルでもそうなので、何かの理由で4.1系統に移行しない理由があるのだろう (ライセンスや安定性だろうか。ここまでは流石に興味はない)

https://packages.debian.org/ja/sid/cron (2016-09-05時点で「パッケージ: cron (3.0pl1-128 など)」)

MAILFROMが重要かと言われればそんなことはないので調べ物はここで終わりにしとく。
Rundeck等の代替もある状況でもあるしcrontabは地雷源でもあるのでむしろcrontab自体を使うべきなのか自体から本当は考えたいところ。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3