Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

FTP script suddenly not working from crontab

by joetesta (Novice)
on Jul 17, 2014 at 18:38 UTC ( #1094109=perlquestion: print w/replies, xml ) Need Help??
joetesta has asked for the wisdom of the Perl Monks concerning the following question:

We have a script we've been using (launched from crontab) for several years to upload images using Net::FTP. Recently we began to notice problems where the images were not uploading and errors were appearing in the logs.

In troubleshooting, I've found that presently the program works just fine when launched from cmd line, but when launched from crontab it errors consistently. On the remote server, I can see in the FTP log that the connection is still active, the client is changing directories but the STOR command never appears as it does under normal circumstance. On the client side, when the ftp->put is issued, the response appears to be '227 Entering Passive Mode'

I've tried everything I can think of to track down the cause (firewalls, ephemeral ports, memory leaks) but so far my only solution is to run it manually from the cmd line.

Does anyone have any idea what might be the cause of this problem? tyvmia

  • Comment on FTP script suddenly not working from crontab

Replies are listed 'Best First'.
Re: FTP script suddenly not working from crontab
by Laurent_R (Abbot) on Jul 17, 2014 at 20:53 UTC
    I dunno if this will help, but I once spent more than a full day trying to fix a small daily Oracle extraction that worked perfectly fine from the shell prompt but produced all kinds of errors when run from the cron tab. The problem had to do with a number of environment variables needed by Oracle that were not set the same way for regular users and for the cron tab user (I guess it was root, not sure to remember correctly though). You might have run into a similar problem: different environment variables.

      I'm sure you've got to be right. It's so strange that it works sometimes. Now I've added to my crontab line a call to the user's .profile and it seems to be working!

      Old user's crontab line:

      * * * * * perl /home/user/data/code/ ftp3 >> /tmp/ftp3.log 2>&1

      New user's crontab line:

      * * * * * . ~/.profile; perl /home/user/data/code/ ftp3 >> /tmp +/ftp3.log 2>&1

      Well that lasted about a minute, timed out and back to errors from crontab

Re: FTP script suddenly not working from crontab
by Anonymous Monk on Jul 18, 2014 at 00:03 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1094109]
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-06-24 06:36 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (557 votes). Check out past polls.