Shell Script to delete files within a particular time frame under multiple sub folders

Greetings!

I'm looking for starting information for a shell script. Here's my scenario:

I have multiple folders(100) for example:
/www/test/applications/app1/logs
/www/test/applications/app2/logs
Within these folders there are log files files that need to be deleted after a month.

I would like for the script to move from app1 to app2 and so forth, find the older file(s) and delete.

App1 and App2 are not the actual names and the real names are quite different.

Assuming the directory structures are the same, i.e., 5 levels:

find /level1/level2/level3/*/logs -type f -mtime +30 -exec rm {} \;

TEST first:

find /level1/level2/level3/*/logs -type f -mtime +30 -exec ls -l {} \;
1 Like

You might want to consider the -delete primary that some find implementations offer.

Jim - I tested first and that works for me. Thanks so much!!

There is so much to learn and I'm so excited that I found this place. I'm going to pour through the message boards and pick up what I can.