Forums

automate delete unused files.

Hello Community. I run Selenium about 4 times a day to gather some date. Twice a month I run out of File Storage. And I have to delete my unused files via Bash console with the command: rm -rf /tmp/ /tmp/. This works perfekly fine for me. But I was wondering, if there is a way to automate this and clean the files right after every scheduled task. This would be really helpful. Thank you.

Sure, you could just add this as the last step of the script.

How can I add it? The rm -rf /tmp/ /tmp/ command doesn't work.

It depends on what kind of script it is -- I guess it's written in Python, so you could implement this using Python; or you could have a Bash wrapper for your original script which would do the clean up if that script finishes successfully. There are many options, but it looks like a general programming issue -- so you could look for similar questions on bigger programming forums, like Stack Overflow.

Okay thank you I will have a look and post my solution here in case someone else need something similar. Do you know how a file is defined as "unused"? Is the file in certain directorie? Or is it just the cache folder?

It's impossible to say, to be honest. You need to nominate them based on your knowledge of the code you are running.

Okay thank you very much.