johnpoint

johnpoint

(。・∀・)ノ゙嗨
github

Linux Delete Large Number of Files

Recently, I checked the log folder of my automatic reconnection script

image

There are too many files, and the rm command prompts that there are too many parameters to execute.

So I wrote a Python script to delete the files.

import os
for pathname,dirnames,filenames in os.walk('/root'):
     for filename in filenames:
         if 'net.log' in filename:
             file=os.path.join(pathname,filename)
             os.remove(file)
print("OK")
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.