How to delete a Gurobi logfile

I have a model which runs multiple times with different input data. For each run I create a folder and place the Gurobi-Logfile within, by passing the Logfile-parameter to the optimizer after creating the model.
After the model is solved I upload the results and the lofgile to a database at which point I would like to delete the created folder including the Gurobi-logfile. However, I get the following error:

IOError: unlink(“[…]\Gurobi_log.txt”): resource busy or locked (EBUSY)

My question is how do I close the logfile?

Following the Gurobi documentation: https://www.gurobi.com/documentation/9.5/refman/logfile.html#parameter:LogFile

Determines the name of the Gurobi log file. Modifying this parameter closes the current log file and opens the specified file. Use an empty string for no log file.

So I assume you just need to pass an empty string "" as the new log file name before trying to delete the former.

If that doesn’t work:

How are you calling Gurobi?

Are you creating multiple models? Or re-using an environment?

1 Like

So I assume you just need to pass an empty string "" as the new log file name before trying to delete the former.

Sometimes the easiest solutions are hard to find :smiley: Thank you very much!