Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-11-2007, 09:23 AM   #1
LQ Newbie
Registered: Jul 2007
Posts: 8

Rep: Reputation: 0
scripted scp when file size changes

I would like to scp a file from one linux box to another when the size of the folder changes (up or down). I assume there would be a script involved, but I am not sure a) how I would write the script, and b) how I could get that script to run whenever file size changed (or as frequently as possible scp if the file size has changed)
Old 09-11-2007, 09:41 AM   #2
LQ Newbie
Registered: Sep 2007
Posts: 12

Rep: Reputation: 0
I can't think of a nice way of doing this. The easy answer is creating a frequent running cron job to ls the file, compare the size to the last ls output, and scp if different.
What is changing your file in the first place? Is it not possible to tag something onto that process to achive your goal? Is the file being changed within unix in the first place, or externally like through a samba share?
Old 09-11-2007, 10:03 AM   #3
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
The other way is finding out what has been written for that purpose already.
monit looks like an option:
You may use monit to monitor files, directories and devices for changes, such as timestamps changes, checksum changes or size changes.

I thought cacti or nagios would have support for directory or file size checksums but I could not find that, yet ...
Maybe have a look for yourself.

Other options might be:
- pikt:
Although it looks like it can only handle files instead of directories.
- zabbix: Looks a littlebit too big for this simple purpose.

Last edited by muha; 09-11-2007 at 10:18 AM.
Old 09-11-2007, 01:05 PM   #4
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
If I were you I would write a script that backs up that directory or file every day. Keep the directory or file for a cycle of days, for example a 7 day cycle. After the 7 day period you would have another script watching and removing any directory or files older than 7 days, thus keeping you maintenance free and not having to worry about space. Of Course there is one requirement for this and thats usually space, lots of it and that depends on what you are trying to backup. The best part about what you are trying to do is that you have two sources of redundancy, 1 your local server and second where you are scp-ing to! Or at least thats what I read your trying to do..... do I understand your situation right? If so I have several scripts that already do this on our production and development servers, be glad to help!
Old 09-11-2007, 02:45 PM   #5
LQ Newbie
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
I am looking at monit, and it looks like it will do the trick.

Thanks for all the help!
Old 09-11-2007, 02:45 PM   #6
LQ Newbie
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
I am looking at monit, and it looks like it will do the trick.

Thanks for all the help!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SCP: No such file or directory...but its there!? Baix Linux - Newbie 20 07-28-2012 03:42 PM
Trying to scp a file, why do I get this? EnVoy Linux - Newbie 2 06-28-2007 07:36 PM
any ideas to reduce log file size or make log file size managed? George2 Programming 2 08-13-2006 07:55 AM
file system size larger than fysical size:superblock or partition table corrupt klizon Linux - General 0 06-18-2004 05:18 PM
SCP ??? where did the file go ?????? lub0 Linux - Security 3 10-07-2003 06:19 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration