Solved

Hung process,  Net::Ftp

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now