-
Dec 24th, 2007, 06:02 PM
#1
Thread Starter
Frenzied Member
Perl script - monitoring a directory
Does anyone know how to create a perl script or a bash script (whichever works the best) that monitors a specific directory and then copies the NEW files and directories that were created since the last check? Is it possible to do this?
For instance, if i have a directory with a bunch of text documents in a bunch of different folders that sits on the server and then on a computer it has the same folders and files but the computer files will be updated. The server is a backup server. So the the program checks to see what directories and files are there. Then the next check it notices 2 new folders and 10 files compared to the backup directory on the server. It should then copy the files and folders from the computer machine to the backup folder on the server.
-
Dec 25th, 2007, 11:22 PM
#2
Re: Perl script - monitoring a directory
This sounds like a perfect use case for rsync.
rsync will synchronize the contents of two directories (possibly on different machines), copying only what has changed between the two.
basically, you say:
Code:
rsync -av /source/dir@source /dest@dest
which synchronizes copies the (updated) contents of the directory /source/dir on the computer source to the directory /dest on the computer 'dest'.
Check the man pages or google for more information.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Dec 25th, 2007, 11:26 PM
#3
Thread Starter
Frenzied Member
Re: Perl script - monitoring a directory
Well the one machine is a windows machine, so am I going to have to run an rsync server on that machine or could i just mount the samba share to a directory like /mnt/smb and sync the two directories locally on the machine?
-
Dec 26th, 2007, 09:00 AM
#4
Re: Perl script - monitoring a directory
Unison is a file synchronization program based on the rsync algorithm and runs on linux/mac/windows/solaris. I have found it to be easy to use in my experience with it.
-
Jan 1st, 2008, 04:07 PM
#5
Re: Perl script - monitoring a directory
I second that. I use unison on Network shares, multiple OS'es and to update websites in a production environment along with change management tools.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|