几天后 Perl 进程消失

标签 perl centos rhel

我有一个 perl 文件 (test.pl)。

它将以循环方式工作。 该文件的目的是从数据库发送电子邮件

下面是test.pl中的代码

sub send_mail{

$db->connect();

# Some DB operations #
# Send mail #

$db->disconnect();
sleep(5);

send_mail();

}

send_mail();

我正在执行这个文件的 5 个实例,如下所示

perl test.pl  >> /var/www/html/emailerrorlog/error1.log 2>&1 &
perl test.pl  >> /var/www/html/emailerrorlog/error2.log 2>&1 &
perl test.pl  >> /var/www/html/emailerrorlog/error3.log 2>&1 &
perl test.pl  >> /var/www/html/emailerrorlog/error4.log 2>&1 &
perl test.pl  >> /var/www/html/emailerrorlog/error5.log 2>&1 &

如果我执行命令 ps -ef | grep perl | grep -v grep

我可以看到上面提到的 perl 文件的 5 个实例

该文件可以完美运行几天

但几天后,perl 进程将开始一个接一个地消失。

几天后所有进程都会消失。 现在。如果我执行命令 ps -ef | grep perl | grep -v grep ,我看不到任何进程,

我在日志文件中看不到任何错误日志。

那么,perl 进程消失的可能性有多大?

我该如何调试它?

我在哪里可以看到 perl 错误日志?

Centos 和 Red Hat Linux 有同样的问题

有人知道吗?

最佳答案

我不是 100% 确定这是否是问题所在,但如果您避免在永久执行的进程中进行递归,这可能会有所帮助……这会慢慢增加堆栈的使用,并最终在堆栈大小限制为达到。

尝试这样的事情:

sub send_mail{

   $db->connect();

   # Some DB operations #
   # Send mail #

   $db->disconnect();

}

while (1) {
   send_mail();
   sleep(5);
}

关于几天后 Perl 进程消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22166614/

相关文章:

python - 全局安装 Python-docx 的正确位置

ruby - 如何在 Redhat 上安装 ruby​​?找不到 ruby 包

java - RHEL : JDK 7u15 installation error

perl - 从 Perl 模块导入条件编译函数

docker - 预创建检查错误 : "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"

perl - 在 Perl 哈希中查找最近的选项

linux - 在 Linux 中持久存在的环境变量的设置

Java 打印线程卡住 : WHY?

perl - 如果数组的任何元素与另一个数组匹配,则打印数组散列的键

regex - 希望 perl 正则表达式替换重新开始并避免 `1 while` 技巧