In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of how to delete directory files regularly under Linux, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this Linux article on how to delete directory files at a regular time. Let's take a look.
To delete all files in a directory regularly, you need to use linux's crontab command, which can be implemented with a shell script. For example, delete all cache files under / tmp as follows:
[root@localhost ~] # vi / etc/init.d/delete.sh press I and copy the following to the delete.sh file, then press shift+: and enter wq to save and exit. #! / bin/bashdir=/tmp / / the directory name files= `ls ${dir} `for file in $filesdoif [- e ${dir} / ${file}]; thenrm-f ${dir} / ${file} fidone
Then give the script 755 permissions with the following code:
[root@localhost ~] # chmod 755 / etc/init.d/delete.sh
Let's use the crontab command to set the time, for example, to clear all files in the / tmp directory at 3 a.m. Every day. Running the following command will enter the vim editing interface.
[root@localhost ~] # crontab-e paste the following code; 0 3 * / etc/init.d/delete.sh save and exit, now the scheduled work has been completed, and automatically empty the files in the / tmp directory at 3 am every morning. Time usage instructions for crontab-e * / etc/init.d/delete.sh timesharing, day, month, week, column 1, month, month, week, week, month, month, week, month, month, 0-6 (0 for Sunday) column 6 is the command to run, for example, run the script at 23:30 every Wednesday night, you can write: 30 23 * 3 / etc/init.d/delete.sh
The same is true for other periods of time.
This is the end of the article on "how to delete directory files regularly under Linux". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to delete directory files regularly under Linux". If you want to learn more knowledge, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.