Find the answer to your Linux question:
Results 1 to 4 of 4
Dear All, Every week i have to download some files from ftp server and copied into offshore Server(Suse Linux) file system. For this task i have to spend more than ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    7

    Cron Jobs in a weekly schedule

    Dear All,

    Every week i have to download some files from ftp server and copied into offshore Server(Suse Linux) file system. For this task i have to spend more than 4 hours in a week.

    So I am planning to put a cron job for downloading files from ftp and put/replace directly into our offshore server.

    I am new in cron jobs.

    Please help me to do that.

    Thanks in advance,

    Moorthy.GS

  2. #2
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    First you should read up on crontab:
    man crontab
    man 5 crontab
    man 1 crontab

    Now let's say you have a script /home/user/ftp.sh and you want to run it every Monday evening at 10 PM. The crontab entry would look like:

    00 22 * * 1 /home/user/ftp.sh > /home/user/ftp.log 2>&1

    This will run script ftp.sh and put all output from stdout & stderr in ftp.log.

    Vic

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    7
    Hey Vic,

    Thanks for your reply...

    Kindly give me sample script for connecting ftp and get the files from that.

    Also how to write a cron job for that operation.


    Thanks,

    Moorthy.GS

  4. #4
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    The script /home/user/ftp.sh could look something like this:

    Code:
    #!/bin/bash -vx
    
    ftp -in host-name<<END_SCRIPT
    quote USER username
    quote PASS password
    bin
    mget filename
    bye
    END_SCRIPT
    Replace 'host-name', 'username', 'password', & 'filename' with the appropriate values.

    Then do '# crontab -e' and add that crontab entry.

    Vic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...