L
L
lolowin322017-05-29 21:29:59
linux
lolowin32, 2017-05-29 21:29:59

How to write script in linux to delete folders with %date% variable?

There is a backup server on Ubuntu, dumps of 1s bases are dumped onto it every night into folders with the% date% variable (dumps weigh about 12 gigs a day), that is, for example, the folder is 05/28/2017 and dumps are in it, respectively, the folder will be created next night 05/29/2017 and dumps for this day and so on will be placed there. It is logical to assume that the space on the railway will someday run out, so I’m thinking how to write a script that would clean up old folders, and leave at least a pool of folders for a month (approximately 30 pieces), I will be glad for any comments

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2017-05-29
@immaculate

Can be used rm -rf $(date +%Y%m%d), canfind /backup -mtime +30 -type d | xargs rm -rf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question