[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Hung process,  Net::Ftp

Posted on 2000-03-02
2
Medium Priority
?
216 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
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

656 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