How to solve the error "Error: EBUSY: resource busy or locked, unlink..." when Linux deletes a folder?

Table of contents

 Problem Description:

 problem solved:


 Problem Description:

On linux, if you want to delete a folder, you always report an error as shown in the figure below, and you can’t delete it all the time. I obviously feel that I have not executed the contents of this folder, but I have been unable to delete it.

 

problem solved:

I have to feel the power of ChatGPT. . I put the question into ChatGPT and its answer helped me solve the problem successfully.

The reason why the deletion has been failing is because there are still running files (although I feel that they are not executing), just find the PID of the running file and delete it.

The specific method is:

1. Execute the following command:

lsof +D /path/to/folder

 Corresponding to my actual situation (the folder Sentiment_SPN_try cannot be deleted), the command entered should be:

lsof +D /home/qtxu/Sentiment_SPN_try

2. Find the PID of the cause of the error

 3. "Kill" the process

kill -9  3883715

4. Delete the previous folder again to delete it successfully.

PS: If you are not at ease, you can also check whether step 3 is successful or not. You can enter the command in step 2 again to check whether the previous error reporting process exists.

 

Guess you like

Origin blog.csdn.net/weixin_41862755/article/details/131492803
Recommended