ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am trying to download, using ftp, a set of files on a nightly basis. The download runs like a champ when executed from the command line. I do have a .netrc file that works when I run it from the command line, but cron doesn't seem to use it. When cron tries to run the script, it hangs. I included the pertinent information below. Any thoughts on why the script hangs when being initiated from cron?
# clear directory for new files
# get the value of yesterday's date
. /<user_home_dir>/scripts/yesterday.sh `date +%m`/`date +%d`/`date +%Y`
# determine file name of image files
# download latest listing files
ftp -n <ftpsite> <<End-of-Session
user <uid> <pwd>
get listings-commercial.txt.gz /<user_home_dir>/data/listings-commercial.txt.gz
get listings-land.txt.gz /<user_home_dir>/data/listings-land.txt.gz
get listings-multi-family.txt.gz /<user_home_dir>/data/listings-multi-family.txt.gz
get listings-residential.txt.gz /<user_home_dir>/data/listings-residential.txt.gz
get $landFile /<user_home_dir>/data/images/$landFile
get $resFile /<user_home_dir>/data/images/$resFile
get $comFile /<user_home_dir>/data/images/$comFile
get $multiFile /<user_home_dir>/data/images/$multiFile
mv listings* /<user_home_dir>/data/download
And here is the information in the log file.
rm: cannot remove `/home/highland/data/download/*.gz': No such file or directory
Connected to <remote addr> (<remote addr>).
220 FTP Server ready.
The file not found is no big deal, the date value shows that the yesterday script is executing correctly, and you can see that I'm connecting successfully to the remote site, but then the process just hangs.
Thanks for the reply, but I'm not sure how that addresses the issue.
The issue is not in clearing up the .txt files on the local machine.
The issue is getting the ftp script to execute from cron. As you can see from the log file excerpt, it connects to the remote machine, but for some reason it does not issue the "get" commands in the ftp script. I'm curious why those commands are not being issued after a successful login.
When I run it from the command line, the script runs just fine, and retrieves all of the files that I am requesting.
So why, when I run the script through cron, does it not issue the "get" statements in the ftp script?