Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do force remove in Python like rm -rf on Linux? [duplicate]

Tags:

python

I want to remove some log files of my App server without shutting down my server. What command can I use to do this using Python, like rm -rf in Linux systems?

Please help.

like image 931
user1344022 Avatar asked Dec 07 '12 15:12

user1344022


1 Answers

shutil is your friend in this instance.

http://docs.python.org/2/library/shutil.html#shutil.rmtree

import shutil
shutil.rmtree("/my/path/to/folder/to/destroy")
like image 191
Alex Couper Avatar answered Sep 28 '22 00:09

Alex Couper