Solved

Hung process,  Net::Ftp

Posted on 2000-03-02
2
214 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 100 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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

707 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