无法在关机/重新启动期间发送Unix邮件

问题描述 投票:1回答:1

我们有一个perl脚本,它将在系统即将关闭时尝试发送电子邮件通知。为此,我们捕获SIGTERM并调用Unix mail命令以在信号处理程序中发送电子邮件。捕获了SIGTERM,但是Unix邮件日志显示在关闭期间,FROM和TO地址已从[email protected]更改为user @ hostname。知道为什么系统会这样做以及如何预防吗? (请注意:当我们运行脚本并从终端终止进程时,同一封电子邮件也可以正常工作)

这是perl代码段:

$SIG{TERM} = \&signal_handler;

sleep(3600);

sub signal_handler { 

my $email_address = '[email protected]';

system("echo \"TestBody\" | mail -s \"TestEmailSubject\" -c \"$email_address\" -r \"$email_address\" \"$email_address\"");

}

这是关机期间/ var / log / mail / mail中打印的内容:

Sep 17 21:17:04 postfix/postfix-script[7009]: starting the Postfix mail system

Sep 17 21:17:10 postfix/master[7011]: daemon started -- version 2.10.1, configuration /etc/postfix

Sep 17 21:17:10 postfix/pickup[10349]: 35F801809C9: uid=0 from=root

Sep 17 21:17:10 postfix/cleanup[10356]: 35F801809C9: message-id=<[email protected]>

Sep 17 21:17:10 postfix/qmgr[10350]: 35F801809C9: [email protected], size=1618, nrcpt=1 (queue active)

Sep 17 21:17:10 postfix/local[10372]: 35F801809C9: [email protected], orig_to=<root>, relay=local, delay=13, delays=13/0.01/0/0, dsn=2.0.0, status=sent (delivered to file: /dev/null)

这是从终端中终止进程的工作情况:

Sep 17 21:20:41 postfix/pickup[10349]: E5328180968: uid=14936 [email protected]

Sep 17 21:20:41 postfix/cleanup[22690]: E5328180968: message-id=<5d814e29.qZd+wgg47afpUdbd%[email protected]>

Sep 17 21:20:41 postfix/qmgr[10350]: E5328180968: [email protected], size=544, nrcpt=1 (queue active)

Sep 17 21:20:41 postfix/smtp[22692]: E5328180968: [email protected], delay=0.06, delays=0.01/0/0/0.05, dsn=2.0.0, status=sent (250 2.0.0 OK 4E/77-59832-92E418D5)
perl email unix postfix-mta sysadmin
1个回答
0
投票

后缀系统可能在关闭过程中比脚本更早地关闭。您是否已在脚本中确认邮件系统仍在运行中[[after您的脚本已尝试发送电子邮件?]]

© www.soinside.com 2019 - 2024. All rights reserved.