?
Solved

Hung process,  Net::Ftp

Posted on 2000-03-02
2
Medium Priority
?
215 Views
Last Modified: 2008-03-17
I have a robot which is run, via cron, every 15 minutes.  It uses Net::Ftp to connect and download some file from a Ftp server...  The problem is that this service is not 100% reliable.  Sometimes I can't connect, but this is handeled by the Timeout option which I have explicilty set to 20 (Timeout => 20) but this only applies to a connection.  Once I have a valied connection it no longer applies and thats when my problems start...

Sometimes I my be logged in, do an ls and never get a response yet the connection is still alive.  When this happens the whole script hangs.  The real problem is that after about 3-4 days Cron has so many quequed processes that it begins to ingnore or kill off jobs at random and at that point I'm %^%$^%$^%.  Any ideas...?  Something clean.  I already have a shell script that goes in and kills the hung processes but that is dirty and ugly and not the solution.
0
Comment
Question by:guadalupe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
jyu_88 earned 400 total points
ID: 2584192
you can do a timeout in your script taking advantage of an 'alarm' function. 'alarm $timeout' will deliver an ALRM signal to your PERL  process after $timeout seconds , then your own handler can quit out the perl script gracefully. The example in 'perlfunc' manpage is easy enough to follow.                  
eval {
     local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
     alarm $timeout;
     $nread = sysread SOCKET, $buffer, $size;
     alarm 0;
};
if ($@) {
      die unless $@ eq "alarm\n";  
      # propagate unexpected errors
      # timed out
}
else {
     # didn't
}

If you have some means with the remote FTP server admin, you can request them to set 'stalk timeout'. The latter is avaiable for some FTP servers, such as proFTPd.
0
 
LVL 3

Author Comment

by:guadalupe
ID: 2612684
Thanks that did the trick!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question