I'm currently batch processing a bunch (~200 x 200MB) of ascii grid surfaces using some SAGA and GDAL algorithms in QGIS and have been running into "out of storage" errors. The issue is that between runs of the model, the /tmp folder fills up after 7-8 surfaces are processed. Performing an "rm -r /tmp/*" between runs clears up space to restart the model. The /tmp folder isn't abnormally small (4g).

I'm not sure how unorthodox it would be to have QGIS send a command between runs to clear the /tmp folder but I'm curious to know how this could be automated (perhaps in python?) to run at the end of a model run. Any other solutions for processing lots of grids would be welcome

1 Answer 1


You could create a custom script in your model to clear the '/tmp' folder at the end of each run. There's numerous ways to delete files but I like to use shutil.rmtree which deletes all files/folders in a specified directory.

To do this, go to Processing Toolbox > Scripts > Tools > Create new script and copy the following (adjust the path):

import shutil


Save the script into C:/Users/You/.qgis2/processing/scripts (again, adjust path as I use Windows). Then add the custom script from the list of algorithms to your model. To add it at the end of the model, check the image:


Now when you run your model in a batch process, it should clear the '/tmp' folder after each run.

  • 1
    That's fantastic! I had no idea that you could add custom scripts into the model-builder. Thanks! Jan 19, 2016 at 16:20
  • 1
    @TrevorJ.Smith - Most welcome buddy! Haha yeah, it's pretty useful to add custom scripts when you have some idea how they work :). Hope it works for you!
    – Joseph
    Jan 19, 2016 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.