LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-23-2009, 02:16 AM   #1
b-RAM
Member
 
Registered: Apr 2009
Distribution: OpenSuse, Slackware
Posts: 70

Rep: Reputation: 15
find command to search file modified


Hi all, sorry for disturb your time, need help please .
Can i search file in linux using find command to search file which
had been modified by user samba in between time from 8am till 5pm ?

i need that for my process backup so the hd backup will backup just the file which had been modified not all files.


Thank's a lot and need reply please.
 
Old 04-23-2009, 08:57 PM   #2
bsdunix
Senior Member
 
Registered: May 2006
Distribution: BeOS, BSD, Caldera, CTOS, Debian, LFS, Mac, Mandrake, Red Hat, Slackware, Solaris, SuSE
Posts: 1,761

Rep: Reputation: 80
How's about this for starters?

Save the script to file name of your choosing, such as "findfile.sh". And then make it executable to run it.
Code:
chmod +x findfile.sh
./findfile.sh
Code:
#!/bin/sh

# Inclusive time to search.
START=`date "+%Y%m%d0800.00"`
END=`date "+%Y%m%d1700.00"`
# Directory to search.
SEARCH="/"
# Username of files.
USER="samba"
# Temporary place to put scratch files.
TMPDIR="/tmp"

# Scratch files.
touch -t $START $TMPDIR/START
touch -t $END $TMPDIR/END

# Find the modified files.
find $SEARCH -type f -user $USER -cnewer $TMPDIR/START ! -cnewer $TMPDIR/END -exec ls {} 2> /dev/null \;

# Cleanup scratch files.
rm $TMPDIR/START
rm $TMPDIR/END

Last edited by bsdunix; 04-24-2009 at 07:46 AM.
 
Old 04-23-2009, 08:57 PM   #3
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
First of all, you can't tell who modified the file. You can only tell when it was last modified. Second, I'm a little puzzled by your 8 to 5. Wouldn't you want anything that had been modified since your last backup? If someone came in early or stayed late and modified files, then . . .

Anyway, check the man page for find. The search `find / -mmin -480` will find all files that were modified in the last 8 hours. Run that search at 5pm, and you have what you want.
 
Old 05-26-2009, 11:39 PM   #4
b-RAM
Member
 
Registered: Apr 2009
Distribution: OpenSuse, Slackware
Posts: 70

Original Poster
Rep: Reputation: 15
Hi all, thanks for all your kind replies anyway, for now i just used find
command combine with rsync maybe something like this:
Code:
find /home/* -type f -mtime 0 -exec rsync -avz {} /destination \;
but i have a question again can i use some option on rsync maybe include files or exclude(to block *.mp3 files when backup process) cause i had try
something like this:
Code:
find /home/* -type f -mtime 0 >> find.txt
from that find.txt files it's contains full path directory files and i just want to try to use rsync for backup using that find.txt file so rsync just backup files with the directory on based on that find.txt files, here i post some of that files:
Code:
/home/warehouse01/Documents/Warehouse/stocks.xls
Need advise please and thank you.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
giving search-string(s) from a file to linux "find" command Fond_of_Opensource Linux - Newbie 3 02-02-2009 06:14 PM
how to find out the user who modified a file in Linux venkat_k Programming 2 01-06-2009 02:51 AM
Track/Trace which process/command modified some file ? Horos23 Linux - Security 1 06-28-2007 01:17 PM
pattern search through find command. abhi Linux - Newbie 2 04-11-2005 10:31 AM
Find out if a file was modified in the last 2 minutes.... cricos Programming 5 04-06-2005 02:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:00 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
Open Source Consulting | Domain Registration