LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-14-2018, 09:16 AM   #1
overlord73
Member
 
Registered: Apr 2004
Location: ..where no life dwells..
Posts: 541

Rep: Reputation: 30
script to remove files older than // modification time


Hi,

a public share (samba, OpenMediaVault) is used for temporary file sharing.
My intention is to keep this share clearly arranged and remove all files older than 30 days.
Therefore daily script is running:

Code:
find '/mountpoint/' -mtime +29 -type f -delete
For newly created files it is okay, but the problem is, that if a file was copied from another host to this share, the modification date doesn't change. The file keeps the old date and during the next scheduled run the script deletes this file.

Any ideas how I can fix this issue? Is there an option that samba always sets a new modtime while copying or does another solution exists?

thx
 
Old 08-14-2018, 10:10 AM   #2
lougavulin
Member
 
Registered: Jul 2018
Distribution: Slackware,x86_64,current
Posts: 279

Rep: Reputation: 100Reputation: 100
Well, how do you do the files copies on your temporary file sharing ?
 
Old 08-14-2018, 12:59 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
You can use "ctime" rather than "mtime". That will tell the last time anything in the inode changed (other than the automatic "atime" update due to the file being read).

Having a copied file retain the mtime of the original is standard DOS/Windows behavior.
 
Old 08-15-2018, 12:14 AM   #4
overlord73
Member
 
Registered: Apr 2004
Location: ..where no life dwells..
Posts: 541

Original Poster
Rep: Reputation: 30
hm ok, thx!
Indeed ctime seems to do the job. Usually the copy process is from Windows-Hosts.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to remove files older than 3 days rust8y Linux - General 26 10-04-2012 08:26 AM
Bash script to remove files older than x days henkoslaw Linux - General 1 06-10-2012 03:55 AM
[SOLVED] Script: find, compress, remove original files, older than x days? blacklion Linux - General 5 02-27-2012 10:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:45 PM.

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