L
L
Lubovka9992017-06-18 12:23:23
CentOS
Lubovka999, 2017-06-18 12:23:23

Centos clear folder contents, files by date?

Hello everyone, how to clear files in a folder by date, for example, there are three files,
1.tpl - 02/18/2017
2.tpl - 02/17/2017
3.tpl - 02/16/2017
How to clear a folder by cron, deleting files older than 1 day, that is, the date files on the 16th and 17th should be deleted.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
roswell, 2017-06-18
@lubovka999

find /path/to/folder/1 /path/to/folder/2 -type f -mtime +0 -delete

Well, on the first run, it makes sense to replace -delete with -print to make sure that exactly the right files get into the candidates for deletion.

D
Dmitry, 2017-06-18
@Tabletko

man find

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question