Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to delete directory and files more old than a week

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
GabrieleMax
Posts: 126
Joined: 2016-09-07 20:24
Location: Senigallia (AN) - Italy
Has thanked: 4 times
Been thanked: 1 time
Contact:

How to delete directory and files more old than a week

#1 Post by GabrieleMax »

Hi everybody!

I use my Stretch server also like a nas for my ipcameras and I'd like to delete everything more old than a week!

For example now I have:

Code: Select all

root@Server01:/home/ipcam# ls
20170407  20170409  20170411  20170413  20170415  20170417  20170419
20170408  20170410  20170412  20170414  20170416  20170418  test
root@Server01:/home/ipcam#
Today I should have just directory from 12 to 19 april, I tryed in crontab this "script" but it doesn't work:

Code: Select all

find /home/ipcam/* -mtime +7 -delete 
Thanks in advance for your help! :)

GabrieleMax

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: How to delete directory and files more old than a week

#2 Post by Dai_trying »

If you are running this script as root you will probably need to put the full path to find (ie /usr/bin/find) in the crontab entry.

GabrieleMax
Posts: 126
Joined: 2016-09-07 20:24
Location: Senigallia (AN) - Italy
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: How to delete directory and files more old than a week

#3 Post by GabrieleMax »

Dai_trying wrote:If you are running this script as root you will probably need to put the full path to find (ie /usr/bin/find) in the crontab entry.
Ok, I did it, on a newsgroup someone wrote me this:

Code: Select all

find . -depth -mtime +7 -print0 | xargs -0 -- rm -rf
It could happen to have a directory more old than a week but with new and old files inside...

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: How to delete directory and files more old than a week

#4 Post by Dai_trying »

As a side note, have you tried using ZoneMinder I used it to set-up a camera monitoring solution a while back and it has the option to only keep x amount of data (settable by time or size), it was very useful to me.

GabrieleMax
Posts: 126
Joined: 2016-09-07 20:24
Location: Senigallia (AN) - Italy
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: How to delete directory and files more old than a week

#5 Post by GabrieleMax »

Dai_trying wrote:As a side note, have you tried using ZoneMinder I used it to set-up a camera monitoring solution a while back and it has the option to only keep x amount of data (settable by time or size), it was very useful to me.
Thanks for your other reply! :)

Yes, I tryed it 4-5 years ago but I don't remember why I stopped to use it... maybe I could/should try to use it today!

It could be useful if you have a smarttv with a webbrowser, so it could be possible to see everycams on every tv, when I'm outside I use Tinycam on android smartphone by vpn/ssl tunnel.

GabrieleMax

Post Reply