Hi, I have a requirement where I need to run my perl script for x hours ( which should be configurable ). Since the script processes thousand's of accounts, it will definitely take more than x hrs.
There are 2 parts of question : - *(A) How to stop after x hours. I cannot run under crontab as X is variable and set as per admin req. ? * Can I use $SIG{ALRM} to be invoked after x hrs ? Is this recommended ? *(B) How do I stop the script graceful without killing the processes and stop from other sunbprocesses being spanned ?* Here is my code snippet : - use Parallel::ForkManager; my $pmgr = Parallel::ForkManager->new($MAX_PROC); foreach my $acct (@$accts) { $pmgr-> run_on_start( sub { my ($pid,$ident)=@_; print "** $ident started, pid: $pid **\n"; } ); $pmgr->start($acct) and next; -- -- -- Here comes my specific task for subprocess -- -- $pmgr->finish(); } $pmgr->wait_all_children(); return \%data; } Since at a time I am running X- Processes, I dont want them to hardkill as each thread is doing critical atomic operation. How can I stop after x hours from spanning any new subprocess and let the running process to complete. Regards, Punit