03 December 2010

Let's automatize it!!!

I have devised a way to automatize the synchronization of files over ftp using lftp. I found the inspiration on as I told you in my previous post. I have written a here document like this:
#! /bin/bash
#script to automatize synchronization using lftp

lftp <<EOF
open -u user,password -p [port] [server]
mirror -c -e /remote_directory /local_directory
open -u user,password -p [port] [server]
mirror -c -e -R /local_directory /remote_directory

Now you know the drill:
I gave it execute permission: chmod +x
Then I put it in my $PATH (/usr/local/bin is a nice place to visit ;))
I added it to my crontab (or anacrontab if you prefer)

That's it!!! Now my directories synchronize automatically everyday. Maybe there is an ever better way to do it but that's the way I devised it and it works!!!

UPDATE: As usual there seems to be a better way to achieve this. I have found it here You can use 'at' with lftp:

lftp at 00:00 ... & (Thus the process runs in the background at 12)