Cron Jobs for FTP download


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cron Jobs for FTP download
# 1  
Old 09-10-2007
Cron Jobs for FTP download

Dear All,

Please to be inform you,I have posted one thread on this forum last 5 days back. I was not getting suggestions for my thread. So i am creating a new thread with detailed of my R&D.

I am new in Shell Scripts, Perl and Cron Jobs. I have one requirement in Cron jobs for FTP Download. Presently i am

downloading around 600 MB files from ftp server manually in every monday. This will affect our internet bandwidth

during office hours. For avioding this, i am planning to schedule cron jobs for my download process.

Download Process to be performed in SUSE Linux. Becoz Downloaded files to be replaced into that server only.

My requirement,

1) I have to stop my server before start the download process. I have given below scripts for stop server process

manually.

login as endeca
password end123

a)endeca# . .endeca_apt
b)endeca# cd bin/
c)endeca/bin# RunCommand apt_control.script apt_stop

a)endeca# . .endeca_auto
b)endeca# cd bin/
c)endeca/bin# RunCommand auto_control.script auto_stop

a)endeca# . .endeca_chrome
b)endeca# cd bin/
c)endeca/bin# RunCommand chrome_control.script chrome_stop

a)endeca# . .endeca_babe
b)endeca# cd bin/
c)endeca/bin# RunCommand babe_control.script babe_stop

How can i write scripts with should be stopped my server process in differnt user?

2) I have to download files from four source folders Like /Source/Dumps1/*, /Source/Dumps2/*, /Source/Dumps2/*,

/Source/Dumps2/*. This will possible on root user only.

FTP Host is 10.10.10.100 port 21
user abc
password defgh

3) Downloaded files are replaced into my Destination folder like /space/endeca/apt/, /space/endeca/auto/,

/space/endeca/chrome/, /space/endeca/babe/ - This will possible on root user only. Is there need to delete the old

files in that four folders?

4) Once Files are moved into destination path. I have to change the ownership of that files like below

root# chown endeca:endeca /space/endeca/apt
root# chown endeca:endeca /space/endeca/auto
root# chown endeca:endeca /space/endeca/chrome
root# chown endeca:endeca /space/endeca/babe

5) Once change ownership is over, i have to restart the server process

login as endeca
password end123

a)endeca# . .endeca_apt
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand apt_control.script apt_start

a)endeca# . .endeca_auto
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand auto_control.script auto_start

a)endeca# . .endeca_chrome
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand chrome_control.script chrome_start

a)endeca# . .endeca_babe
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand babe_control.script babe_start

I have written ftp scripts for download. My doubt is i have to write four script for downloading four folders. Also

i have to schedule four cron jobs for my tasks.

#!/bin/bash -vx
ftp -in 10.10.10.100<<END_SCRIPT
quote USER abc
quote PASS defgh
bin
prompt off
cd /Source/Dumps1/
lcd /space/endeca/apt/
mget *
bye
END_SCRIPT

Please don't take bore of my post.


Thanks in advance,

Moorthy.GS
# 2  
Old 09-10-2007
Quote:
Originally Posted by moorthygs
Dear All,

Please to be inform you,I have posted one thread on this forum last 5 days back. I was not getting suggestions for my thread. So i am creating a new thread with detailed of my R&D.

I am new in Shell Scripts, Perl and Cron Jobs. I have one requirement in Cron jobs for FTP Download. Presently i am

downloading around 600 MB files from ftp server manually in every monday. This will affect our internet bandwidth

during office hours. For avioding this, i am planning to schedule cron jobs for my download process.

Download Process to be performed in SUSE Linux. Becoz Downloaded files to be replaced into that server only.

My requirement,

1) I have to stop my server before start the download process. I have given below scripts for stop server process

manually.

login as endeca
password end123

a)endeca# . .endeca_apt
b)endeca# cd bin/
c)endeca/bin# RunCommand apt_control.script apt_stop

a)endeca# . .endeca_auto
b)endeca# cd bin/
c)endeca/bin# RunCommand auto_control.script auto_stop

a)endeca# . .endeca_chrome
b)endeca# cd bin/
c)endeca/bin# RunCommand chrome_control.script chrome_stop

a)endeca# . .endeca_babe
b)endeca# cd bin/
c)endeca/bin# RunCommand babe_control.script babe_stop

How can i write scripts with should be stopped my server process in differnt user?

2) I have to download files from four source folders Like /Source/Dumps1/*, /Source/Dumps2/*, /Source/Dumps2/*,

/Source/Dumps2/*. This will possible on root user only.

FTP Host is 10.10.10.100 port 21
user abc
password defgh

3) Downloaded files are replaced into my Destination folder like /space/endeca/apt/, /space/endeca/auto/,

/space/endeca/chrome/, /space/endeca/babe/ - This will possible on root user only. Is there need to delete the old

files in that four folders?

4) Once Files are moved into destination path. I have to change the ownership of that files like below

root# chown endeca:endeca /space/endeca/apt
root# chown endeca:endeca /space/endeca/auto
root# chown endeca:endeca /space/endeca/chrome
root# chown endeca:endeca /space/endeca/babe

5) Once change ownership is over, i have to restart the server process

login as endeca
password end123

a)endeca# . .endeca_apt
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand apt_control.script apt_start

a)endeca# . .endeca_auto
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand auto_control.script auto_start

a)endeca# . .endeca_chrome
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand chrome_control.script chrome_start

a)endeca# . .endeca_babe
b)endeca# ./start_em.sh
c)endeca# cd bin/
d)endeca/bin# RunCommand babe_control.script babe_start

I have written ftp scripts for download. My doubt is i have to write four script for downloading four folders. Also

i have to schedule four cron jobs for my tasks.

#!/bin/bash -vx
ftp -in 10.10.10.100<<END_SCRIPT
quote USER abc
quote PASS defgh
bin
prompt off
cd /Source/Dumps1/
lcd /space/endeca/apt/
mget *
bye
END_SCRIPT

Please don't take bore of my post.


Thanks in advance,

Moorthy.GS
You can do the task by means of a single shell script itself and by means of a single cron?
# 3  
Old 09-10-2007
Cron Jobs for FTP Download

Hey,

Thanks for your reply.

Hope it is not possible for single shell script. But it can possible on single cron job.

Please guide me.

Cheers,

Moorthy.GS
# 4  
Old 09-10-2007
Java

#!/bin/bash -vx
ftp -in 10.10.10.100<<END_SCRIPT
quote USER abc
quote PASS defgh
bin
prompt off
cd /Source/Dumps1/
lcd /space/endeca/apt/
mget *
cd ..
cd Dumps2/
lcd /space/endeca/auto/
mget *
cd ..
cd Dumps3/
lcd /space/endeca/chrome/
bye
END_SCRIPT

I think the above script will do the task for you,if you schedule it through crontab.

With Regards
Dileep Pattayath
# 5  
Old 09-11-2007
Cron Jobs for FTP Download

Hey Dillip,

Thanks for your guidance,

I modified your shellscript as per my requirement. code is below

#!/bin/bash -vx
ftp -in 10.10.10.100<<END_SCRIPT
quote USER abc
quote PASS abcded
bin
prompt off
cd /csi/endeca_chrome/dgraph_input/
lcd /home/endeca/chrome/
mget *
cd ..
cd /csi/endeca_autos/dgraph_input/
lcd /home/endeca/autos/
mget *
cd ..
cd /csi/endeca_babe/dgraph_input/
lcd /home/endeca/babe/
mget *
cd ..
cd /csi/endeca_apt/dgraph_input/
lcd /home/endeca/babe/
mget *
bye
END_SCRIPT

I have scheduled last night 2 AM for my download process. Here below crontab entries....

00 02 * * 2 /root/ftp.sh > /root/ftp.log 2>&1

But only 3 files copied to /home/endeca/chrome/ location.

I have pasted my ftp.log entries for your reference. Please help to fix it.

#!/bin/bash -vx
ftp -in 216.251.248.151<<END_SCRIPT
+ ftp -in 216.251.248.151
Interactive mode off.
Local directory now /home/endeca/chrome
'EPSV': command not understood

Cheers,

Moorthy.GS
# 6  
Old 09-13-2007
Please try the below code :

#!/bin/bash -vx
ftp -in 10.10.10.100<<END_SCRIPT
quote USER abc
quote PASS abcded
bin
prompt off
cd /csi/endeca_chrome/dgraph_input/
lcd /home/endeca/chrome/
mget *
cd /csi/endeca_autos/dgraph_input/
lcd /home/endeca/autos/
mget *
cd /csi/endeca_babe/dgraph_input/
lcd /home/endeca/babe/
mget *
cd /csi/endeca_apt/dgraph_input/
lcd /home/endeca/babe/
mget *
bye
END_SCRIPT

It's working for me and also take a look at the permissions fot the files.

'EPSV': command not understood
was not an error.It was trying to use the extended passive mode ftp.If it was not supported it will automaticall return back to PASV mode.

With Regards
Dileep Pattayath
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Cron jobs

I'm running cronjobs on a redhat 5.X. Cronjobs are getting failed frequently so how to find the root cause (2 Replies)
Discussion started by: karthik9358
2 Replies

2. Solaris

Cron jobs and at jobs

There are two jobs in Solaris , Cron and at jobs.. I know how to disable or enable cron jobs. How can I enable at jobs and disable it. Kindly help. Rj (2 Replies)
Discussion started by: jegaraman
2 Replies

3. Linux

Cron jobs

Hi, I am a Linux administrator (newbie) in my company. The distro being used in the servers here is Centos 5.3 Just need to know, as a Linux administrator is it better for me to use /etc/crontab to set my cron jobs. I do not want to use the crontab -e to schedule my cron jobs. That means... (1 Reply)
Discussion started by: anaigini45
1 Replies

4. UNIX for Advanced & Expert Users

cron jobs...

I need to start a job every friday night at 8:00 P.M , it runs all the day on Sat and Sun....can somebody tell me how to do this...I understand crontab...but haven't used it.........can u write some steps.....how to create a file and call.....I honestly dont know? Plz help.Thanks (2 Replies)
Discussion started by: RubinPat
2 Replies

5. Linux

cron jobs

I created a php script. I'd like to have it run as a cron job every day at 10:30am. So i added 30 10 * * * /script.php to the cron file Is it possible to run the script on the command line to test it out ? (1 Reply)
Discussion started by: dannyd
1 Replies

6. Solaris

Cron Jobs

I'm trying to run cron jobs to start any inhibited processes after a system reboot. I can schedule th cron, but i'm confused as to how to incorporated the reboot, since reboot is scheduled at different times, once every month. How can I write this to start every 15 min after after a reboot ... (2 Replies)
Discussion started by: Remi
2 Replies

7. Solaris

Cron Jobs

whats up, Have some questions about cron jobs, I am fairly new to the unix os. My cronjob sends all output to my mail, does anyone know how to redirect output to come out on the screen??? Thanks...... (6 Replies)
Discussion started by: lewisoco
6 Replies

8. UNIX for Dummies Questions & Answers

cron jobs

I was wondering if itīs possible to cron job not to run on a certian day and time. Iīve got a job that runs everyday at 08:00 but would like it not to run on the 20:th between 08:00 and 10:00 Anyone know if this is possible, and if. How do i do it? regards... dOzY (3 Replies)
Discussion started by: dozy
3 Replies

9. Shell Programming and Scripting

cron jobs

hi folks, I need an explanation on cron jobs with an example (4 Replies)
Discussion started by: vijaysabari
4 Replies

10. UNIX for Dummies Questions & Answers

CRON Jobs

Hi, I am a total newbie to all things Unix. I've worked out I need to set up something that will allow me to automatically backup a DB for me, the DB is for a foum system I run. Now, I've only found out I need to use telnet for this, and worked out hwo to log into telnet today. From here... (4 Replies)
Discussion started by: eludlow
4 Replies
Login or Register to Ask a Question