0

I'm trying to create a script to download a file daily with the older version overwritten.

I'm pretty sure I need a cron job, and a shell script with a wget line in it, but that is as far as I know. Also, I need to do all of this through ssh, unless there's another way I'm not aware of.

If I do it through SSH, what commands do I need to use through the various steps in the process? What will the cron and the shell files look like? If there's a better way, please enlighten!

Thanks! Zeem

3
  • Why would you need SSH to automatically download a file? wget already supports SSL. Removing old versions is a job for rm. A cron job is created via crontab -e. Post what you have so far, and people will answer your remaining questions. May 20, 2011 at 14:07
  • I meant using SSH to create the cron job.
    – zeemy23
    May 20, 2011 at 14:16
  • @KilianFoth Sometimes one would like to login via SSH to download files, that should not be publicly accessibly. Backup-Files for example. If anyone could download them, that would be a mess :D
    – Robert
    Oct 17, 2015 at 17:15

3 Answers 3

0

From your description, I'm picturing the following:

  1. connect to the server via SSH
  2. find the location of wget

    which wget

(on my machine it's /usr/bin/wget)

  1. add the following to your /etc/crontab (or cronjobs file) using a text editor, such as pico or vi:

    @daily /usr/bin/wget http://remote-host.name/path/to/file.txt /local/path/to/file.txt

(If you add this to the /etc/crontab, you'll probably need the additional user parameter, but you can see crontab help for that.)

hope that helps.

0

Implement password-less ssh authentication between the hosts. http://www.linuxproblem.org/art_9.html

So host A can create/implement an script or cronjob on host B using ssh.

To create a cronjob by using a script, your script create (for example) an textfile at /etc/cron.d/CronJobName. It is important, that the content of the file corresponds to the corn format: http://en.wikipedia.org/wiki/Cron#Examples

(I hope, I understand your question right)

0

Thanks for your answers, Thankfully it was much simpler. I was able to add a cron job via cpanel, and the wget line went straight in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.