Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-23-2004, 07:28 AM   #1
LQ Newbie
Registered: Mar 2004
Location: london
Distribution: Mandrake 9.2
Posts: 7

Rep: Reputation: 0
triggering bash script if directory modified

I have a linux home box and a Solaris remote backup server
I am trying to write a bash script , so that if I locally save any file in a given directory on my home box , then the script will automatically detect that the directory has been modified and will run the script and backup the content of the directory to the remote server . is that possible ??
Old 10-23-2004, 07:52 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could have a script run periodically by cron. I think that the best way to do it is to use the find command.
You could use the '-newer file' option to find files newer than a certain file. The file you use is simply one you create with the touch command, to create a file that is used as a time-stamp. The file command has an -exec option that can be used to call a command and hand it the list of new files. There is also an option to use a null byte instead of a return character in the list.
After the files are backed up, simply touch the time-stamp file again before finishing.

Last edited by jschiwal; 10-23-2004 at 07:53 AM.


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
Bash script to access all files in a directory shinni Programming 5 04-24-2009 03:46 PM
Using Bash, Find script files in a directory or subdirectories within... ray5_83 Programming 4 10-10-2008 07:42 PM
$LINENO can't be modified in bash 3.0, while it can be in bash 2.05b Darwish Linux - Software 1 11-07-2005 02:57 PM
cd keeps snapping back to current directory when called from bash script ghrellin Linux - General 5 08-28-2005 12:50 PM
Specifying target directory for command in bash shell script? spectrescape Programming 1 07-22-2004 05:37 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:19 AM.

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
Open Source Consulting | Domain Registration