A
A
Andrey2017-12-14 13:08:40
Task Schedulers
Andrey, 2017-12-14 13:08:40

Cron job to delete certain folders after a certain number of days?

there is a directory
/var/www/user/data/www/mysite.com/scrin/ in it a bunch of folders are created every day like this:
04-12-2017
05-12-2017
06-12-2017
.....
.. ...
into which screenshots are loaded.
and not only those
. So here's how to properly hang a cron task so that it deletes only folders of this type from the /var/www/user/data/www/mysite.com/scrin/ directory that are older than 8 days 04-12-2017, without touching others folders?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2017-12-15
@VELIK505

Thank you all, in general, here's who needs it:

@daily find /var/www/user/data/www/mysite.com/scrin -type d -name "*-*" -mtime +8 -exec rm -rf {} \; >/dev/null 2>&1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question