[opensuse] how to know when the last time files have been accessed.
Hi All, I have samba file server that uses as file-sharing (mostly mp3). Right now I want to know which file (mp3) that have been accessed (read), not changed.. So I can delete all music files that stay too long but not played for a long time.. How can I do it ? I try 'ls -lat' .. buat I guess it said which file that have been changed / writed /edited. right ? regards, -- Arie Reynaldi Zanahar reymanx at gmail.com http://www.reynaldi.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Arie Reynaldi Z wrote:
Hi All,
I have samba file server that uses as file-sharing (mostly mp3). Right now I want to know which file (mp3) that have been accessed (read), not changed.. So I can delete all music files that stay too long but not played for a long time.. How can I do it ? I try 'ls -lat' .. buat I guess it said which file that have been changed / writed /edited. right ?
First make certain that atime is enabled on the filesystem of interest. Then it's easy to test for last access time with a shell script, and delete those files which haven't been accessed for whatever time period you decide. Off the top of my head, you could have a cron job do something like: find /path/to/mp3s -atime +90 -exec rm {} \; every day at 0420 or something appropriate. Joe -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Sunday 23 September 2007 19:22, Arie Reynaldi Z wrote:
Hi All,
I have samba file server that uses as file-sharing (mostly mp3). Right now I want to know which file (mp3) that have been accessed (read), not changed.. So I can delete all music files that stay too long but not played for a long time.. How can I do it ? I try 'ls -lat' .. buat I guess it said which file that have been changed / writed /edited. right ?
Each file in a Unix / Linux file system records three time-stamps for each file it holds: - Modify time The most recent time the file's contents were changed - Read time The most recent time the file's contents were read - Change time The most recent time the file's metadata was changed; This includes the file's owner, group, permissions (mode) _and_ its modify and read times. Each of these times is accessible via the stat family of system calls and through various command-line tools, such as ls, find and getfattr, among others. If you're goal is to enumerate files that have been read within some time range, the "find" command is probably the best tool. Read the manual page to find out how to select files based on their access times. Note, too, that any command that reads a file (cp, less, file, zip, tar and many, many others) will alter the access time. Even backup software (poorly written backup software!) can alter the access time of files it saves.
regards,
-- Arie Reynaldi Zanahar
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
- Modify time The most recent time the file's contents were changed
- Read time The most recent time the file's contents were read
- Change time The most recent time the file's metadata was changed; This includes the file's owner, group, permissions (mode) _and_ its modify and read times.
If you're goal is to enumerate files that have been read within some time range, the "find" command is probably the best tool. Read the manual page to find out how to select files based on their access times.
I think using find /path/to/files -atime would be good for my needs.. Thanks regards, -- Arie Reynaldi Zanahar reymanx at gmail.com http://www.reynaldi.or.id -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (3)
-
Arie Reynaldi Z
-
joe
-
Randall R Schulz