What is a reliable way to automate FTP upload of 'the newest file in directory X'?

Make a short script, get the filename via this line:

newestfilename=`ls -t $dir| head -1`

(assuming $dir is the directory you're interested in), then feed $filename to your FTP command, and of course, cron this script to run once a day.

If you have ncftp, you can use the following command to ftp the file:

ncftpput -Uftpuser -Pftppasswd ftphost /remote/path $dir/$newestfilename

Without ncftp, this may work:

ftp -u ftp://username:[email protected]/path/to/remote_file $dir/$newestfilename

Tags:

Ftp

Centos