ftp in cron job


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ftp in cron job
# 1  
Old 07-27-2005
ftp in cron job

I am writing a script that will be placed in a crontab, which basically retrieves a file that is overwritten everyday (with current customer data) and then sent to another company. I was wondering what the best way to ensure that ftp was successful and notification of a success or failure message. Not real sure how to do this, was thinking ftp response codes but not sure how to retrieve them? Any suggestions?
# 2  
Old 07-27-2005
you can use wget instead of ftp, wget has crash recovery so it will keep trying to recover the file if the connection fails, then, you can check if your file exists on the directory you recently downloaded it. I have something like your script on my system, once the file has been retrieved, the script runs the program that uses that file, if the program doesn't recognize the file format (maybe the file is corrupt) it deletes the new one, roll back to the older file and sends me a email about the problem.

or do somenthing like this (tested with ksh):

Code:
THEFILE=some_important_file

if wget ftp://some.place/$THEFILE; then
        echo "OK-"
else
        echo "could not retrieve $THEFILE" | mail -s"$THEFILE ERROR!" admin@yoursite 
fi

..a email will send to you if an error ocurrs,

best regards!

Last edited by infierno; 07-27-2005 at 03:40 PM..
# 3  
Old 07-29-2005
Lightbulb

you culd try ftp (hoast) then if the file that file you sent via e mail is the o the sever thne it works Smilie
# 4  
Old 07-30-2005
thepicoman,

Please review the rules:
https://www.unix.com/unix-for-beginners-questions-and-answers/2971-simple-rules-unix-com-forums.html

Several of your posts are technically misleading or do not contain any solutions/assistance.

At first glance, the following posts:

https://www.unix.com/79709-post2.html
https://www.unix.com/79710-post3.html
https://www.unix.com/79707-post4.html

breach several of our rules, including:

(3) Refrain from idle chatter that does not contribute to the knowledge base.

(9) Edit your posts if you see spelling or grammar errors (don't write in cyberchat or cyberpunk style). English only.


I enforced rule 12 ((12) The forum administrators reserve the right to prune, move or edit posts that do not adhere to the rules or are technically inaccurate.) by removing one of your posts which contained incorrect information regarding the du and df commands.

Please take some care when posting in future, to ensure that your post contains correct technical information, and is actually of assistance to the original poster / other people viewing the thread. We all make mistakes from time to time, but bear the rules in mind when posting.

Thanks,
ZB
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

3. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

4. UNIX for Advanced & Expert Users

cron job to extact lines from files to another file and ftp to new server

i have a text file in this format: which creates a new one everyday in the form of filename _zing__r200_2012_8_10_log.txt Fri Aug 10 07:29:17 EDT 2012, usera(192.168.0.245) to anotheruser: hey top, this is a private test Fri Aug 10 07:29:28 EDT 2012, anotheruser(192.168.0.245) to usera: got... (2 Replies)
Discussion started by: bkkid
2 Replies

5. UNIX for Dummies Questions & Answers

If FTP cron job fails to connect = quit

Im having a problem with my ftp CRON jobs. I have another related (but not the same question in shell scripting). My FTP CRON jobs connect to a server and drop some files off, if for some reason it cannot connect to the server (timesout/password wrong etc) instead of stopping, it tries again... (3 Replies)
Discussion started by: mokachoka
3 Replies

6. Shell Programming and Scripting

Im trying to create a FTP Cron Job

Hello, Im fairly new to this and am hoping for your help in moving forward. 1. I need to carry out a FTP transfer from SERVER1 to SERVER2 at 3am every morning. 2. The FTP is to work on SERVER1 3. There will be many files to transfer (96 files per day) 4. I want to delete the files... (3 Replies)
Discussion started by: nozerf
3 Replies

7. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

8. UNIX for Advanced & Expert Users

Cron FTP job

We have a script that we run manually, we want to set it up so that it will run automatically via cron, the problem is during the ftp process nothing is put, the script logs in changes directory fine, but nothing is put to the directory. I have tried it as root, a power user, etc. I have made the... (4 Replies)
Discussion started by: marvin51796
4 Replies

9. UNIX for Dummies Questions & Answers

CRON usage for CRON job

can anybody explain the usage of CRON for adding a cron job. please provide an example also for better understanding !!! Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies

10. UNIX for Dummies Questions & Answers

cron ftp job help

I am new to cron and am trying to set a cron job that will run everyday at 2 to go out to a server (via ftp with user name and password) and get a file and then bring it back to my sever. Below is what I have but it doesn't seem to be working. Any help would be appreciated. cron command - will... (4 Replies)
Discussion started by: bernfuss
4 Replies
Login or Register to Ask a Question