我最近发现cron
(至少在 Ubuntu 14+ 上)支持一项设置,CONTENT_TYPE
我可以在其中指定电子邮件的内容类型,例如:
CONTENT_TYPE="text/html; charset=utf-8"
在我使用的另一台非 Ubuntu 服务器上,版本不支持此功能。我查看了所有能找到的手册页,但无济于事。有没有办法找出给定版本的所有受支持的设置cron
?
答案1
页面中提到了这man
一点,您只需查看正确的内容即可。
By default, cron will send mail using the mail "Content-Type:" header
of "text/plain" with the "charset=" parameter set to the charmap /
codeset of the locale in which crond(8) is started up - ie. either the
default system locale, if no LC_* environment variables are set, or the
locale specified by the LC_* environment variables ( see locale(7)).
You can use different character encodings for mailed cron job output by
setting the CONTENT_TYPE and CONTENT_TRANSFER_ENCODING variables in
crontabs, to the correct values of the mail headers of those names.
现在你可能会问,我怎么知道该看哪一个。好吧,来自man man
:
下表显示了手册的章节编号以及其包含的页面类型。
1 Executable programs or shell commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) 8 System administration commands (usually only for root) 9 Kernel routines [Non standard]