Cron to delete particular file(s) from a specific directory
66
Solution 1
Try the find
command.
find /somedir1/somedir2 -name *.txt -name *.log -mtime 2w -delete
Change -delete
to -print
for a dry run.
Solution 2
You could also leverage tmpwatch
http://linux.die.net/man/8/tmpwatch, using whichever parameters of atime
, ctime
, or mtime
suit your needs.
For example, tmpwatch --atime 30d /foo
will remove all files in /foo that haven't been accessed in 30 days.
Related videos on Youtube
Author by
user278618
Updated on September 18, 2022Comments
-
user278618 over 1 year
I have class StatusesInvestmentRow (from dataSource) where one of the field is ModifiedDate
Investment table: Id int PK; ModifiedDate datetime;
How can I sort this arrayby this date?
I found example with IComparable but StatusesInvestmentRow has DataRow type so it is not good way I think.
I have this and I can't change this:
statInw = new GetAllInvestmentStatuses();
I want add something like:
var newestStatusInvestment = statInv.Sort(comparerByDate)[0];
-
Mikel over 11 yearsThe
find
command does everything you need.man find
-
-
Paul Sasik over 13 yearsThose select functions return DataRow[]