Skip to content

Instantly share code, notes, and snippets.

@chrislkeller
Last active October 5, 2015 23:17
Show Gist options
  • Save chrislkeller/2893801 to your computer and use it in GitHub Desktop.
Save chrislkeller/2893801 to your computer and use it in GitHub Desktop.
Loop to download a file from FTP, create a symlink to the file and append date and time to subsequent downloads...

Bash script to download file from FTP

Loop to download a file from FTP, create a symlink to the file and append date and time to subsequent downloads...

#!/bin/bash
# open loop
while true
# open the loop action
do
# sets date to date
DATE=`date +%Y%m%d%H%M%S`
# hits ftp and downloads
curl -o $DATE-<FILE NAME HERE> ftp://<USERNAME HERE>:<PASSWORD HERE>@<FTP PATH HERE>
# remove the file
rm <FILE NAME HERE>
# hits ftp and downloads
ln -s $DATE-<FILE NAME HERE> <FILE NAME HERE>
# rests for a minute
sleep 120
# close the loop action
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment