我使用Proc::Daemon模块。我有脚本谁守护我的另一个脚本。但我需要脚本守护进程也是一个守护进程。是否可以使用此模块执行此操作,还是需要单独的脚本? 此代码必须是守护程序
use strict;
use warnings;
use Proc::Daemon;
my $daemon = Proc::Daemon->new(
work_dir => '/home/develop',
child_STDOUT => '/home/develop/child.log',
child_STDERR => '+>>log.txt',
pid_file => 'pid.txt',
exec_command => 'perl /home/develop/test.pl'
);
foreach (@ARGV) {
if (/i/) {
my $Kid_1_PID = $daemon->Init;
my $Kid_2_PID = $daemon->Init(
{ work_dir => '/home/develop',
pid_file => 'pid2.txt',
exec_command => 'perl /home/develop/test.pl',
}
);
} elsif (/r/) {
my $stopped = $daemon->Kill_Daemon();
$stopped = $daemon->Kill_Daemon();
}
}