In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Scene description:
As shown in the following figure: there is a date command directory under the log directory, and there are directories and Log log files in the directory. Because of the space alarm, the previous data needs to be deleted.
Solution:
Of course, we can use the rm command to delete one by one, to test the convenience of operation and maintenance, we write a script to achieve the best. If it is the linux platform, it is actually very simple:
Find ~ / log-maxdepth 1-mindepth 1-type d-mtime + 149 | xargs rm-rf
Just use the above command. But the find command on the AIX platform is less friendly because it has no maxdepth or mindepth parameters. After looking for a few laps, I found that it could be solved with the following command:
# Delete the date directory under the ~ / log/ directory and retain the 365day data find ~ / log/*-prune-type d-name "20*"-mtime + 365-print | xargs rm-rf # # the above command is also equivalent to: find ~ / log/!-name "."-prune-type-d-name "20*"-mtime + 365-print | xargs rm-rf
The key instructions are:
1. The parameter prune, which means that when a directory is encountered, no recursive lookup is performed.
2. Restrictions on the starting directory, ". / *" and ". /" and ". /-name". "" And ". /. These directories are different. ". / *" starts with all the directories and files in the current directory; while ". /" starts from the current directory; ". /-name". "" Except for all the contents thought by the. / directory, it is equivalent to ". / *";. /. " Or the current directory.
Finally, put the above statement into crontab and you can delete the number every day with a scheduled task.
Reference:
1. Question and answer "Equivalent maxdepth for find in AIX" on stackovernet
2. "thinking caused by find Command-prune parameters" written by My Panda Eye.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.