LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-30-2015, 09:08 AM   #1
lexian
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Rep: Reputation: Disabled
writing a script using find and rsync stuck at some issues


Hi
What I'm trying to do is to have a script that search for a file changed last day than rsync the file and its parent directory.
Tried for the past month or two. read about
https://gist.github.com/evgenius/6019316
https://github.com/drunomics/syncd
https://github.com/gregghz/Watcher
as well as incron,incorntab,iwatch,inotify and many more (I just used google), before I landed on trying to write the script because of the main reason being. The parent directory is unknown and randomly generated each day, so I wanted to use wild cards e.g. /path/*/filename.txt but the use of wild cards in path is not supported on those scripts I read or I'm to newbie to figure it out anyway the script so far is this:
I will be running this with incron daily.
#!/bin/sh
find /parent-path-to-unknown-dir -name "filename.txt" -type -f -mmin -$((60*24)) -exec rsync --ignore-exsiting -azR --log-file=/path/ {} /source /destination \;


I'm truly grateful for any pointers and maybe there is even a better way to accomplish the same thing.
 
Old 06-30-2015, 01:10 PM   #2
procfs
Member
 
Registered: Jan 2006
Location: Sri Lanka
Posts: 610

Rep: Reputation: 34
Hi hope this will help but I amy be wrong there is no restrictions in while-cards in shell scripts, I am using them all the time (not that I am an expert script writer)
 
Old 07-01-2015, 02:58 AM   #3
lexian
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by procfs View Post
Hi hope this will help but I amy be wrong there is no restrictions in while-cards in shell scripts, I am using them all the time (not that I am an expert script writer)
Hi
Yes you are correct on that, and that is why I'm trying to use script.
What I need helping to figure out is, if there is a way for rsync to sync the file and the parent folder of the find command.
#this command I find the file called filename.txt that is newer than a day.
find /path/ -name "filename.txt" -type f -mmin -$((60*24))

Than I need rsync to sync not just the file "filename.txt" but also the parent folder.
just not sure how i do this last part?
 
  


Reply


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
Permissions issues when writing a file with PHP script jimbo1954 Programming 5 05-10-2013 11:10 AM
find & rsync script simon_bagola Linux - Newbie 13 01-15-2011 08:33 AM
Writing a poweroff script ,wanted to know where i can find the necessary info! wrapster Solaris / OpenSolaris 6 06-22-2008 02:51 PM
Writing script to find all archives w/ usr/local 1veedo Linux - Newbie 1 01-08-2007 04:31 PM
Writing a script to do a few actions... having issues... Byronious Linux - General 8 11-27-2006 08:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:39 AM.

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