LinuxQuestions.org
Review your favorite Linux distribution.
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 03-05-2008, 04:04 AM   #1
ignarus
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Rep: Reputation: 0
is there a way to check for newly created files without having to access the mount


I'm looking for a way to know if files were created on a mounted usb drive without having to access the drive. The reason is that I have written a script which needs to check for the existence of a certain file periodically. However if I use an ls or find, the drive will never go into sleep state any more.

Is there some way to get this information without disturbing the disk?


Thanks
 
Old 03-05-2008, 04:09 AM   #2
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
If something's writing to the disk, as in creating a particular file, it wouldn't be sleeping anyway ...

You could just ls or cat the file list in long intervals, and run your checks against that, but something tells me you're looking for something both a) easier and b) much harder to implement.

What is the type of file being looked for; e.g. is it automatically generated by a script or other action, does it happen on a schedule, is it something you would have put on there when you loaded the disk, et cetera?
 
Old 03-05-2008, 04:50 AM   #3
ignarus
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Original Poster
Rep: Reputation: 0
The script automatically mounts and unmounts usb disks when they are plugged/unplugged on my linux server machine based on the unique id of the disk and runs at 5 second intervals. I enables me to plug/unplug the devices without having to log on to the system and mount/umount them manually. Because of the caching there is the possibility of data loss when the drive is unplugged without a prior umount so I let the script check for a file called @eject in the root of the disk. If it exists the script will unmount the disk properly.

As you can see this file can be created at any time by a user e.g. via samba. So for example I have a WD500 connected which start sleeping after 15 min of no activity and normally it would be sleeping until somebody accesses it through samba. With the current script however it will never go to sleep. I am aware of the sync and dirsync options for mount to disable caching but I would want to avoid using them. Ideal would be if there was some way for the script to check if there has been some write operation for the disk but I don't know if this info is kept somewhere by the OS.
 
Old 03-05-2008, 05:01 AM   #4
ignarus
LQ Newbie
 
Registered: Nov 2004
Posts: 17

Original Poster
Rep: Reputation: 0
ok I think I posted too quickly . The last modified date of the mount point seems to be updated when a write operation is performed on the disk. This way I don't need to go into the moint point to know if there has been a write operation.
Thanks anyway for the reply!
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
canīt access the newly created EXT3 partition by GPARTED in kubuntu mehdiee Linux - Newbie 3 02-15-2008 04:04 PM
Slack 11 won't mount newly created partitons JimBass Slackware - Installation 5 10-22-2006 04:52 PM
FTP, newly created files permission georgiozoze Linux - Newbie 2 09-16-2006 09:47 PM
permissions for newly created files dialbat Linux - General 2 10-04-2004 03:58 PM
Can we access the newly created files after dd if=hda6_last_mon_backup of=/dev/hda6 murugesan Linux - Software 0 03-29-2004 09:42 AM


All times are GMT -5. The time now is 07:28 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration