【转】shell脚本执行时报"bad interpreter: Text file busy"的解决方法

时间:2023-03-09 14:22:28
【转】shell脚本执行时报"bad interpreter: Text file busy"的解决方法

1)问题现象:

在ubuntu下执行以下脚本( while_count),报错:

-bash: ./while_count: /bin/bash: bad interpreter: Text file busy

2)问题原因:

This happens because the script file is open for writing, possibly by a rogue process which has not terminated.

3)解决办法:

Solution: Check what process is still accessing the file, and terminate it.

Run lsof (list open files command) on the script name:

lsof | grep while-count
cat 17653 me   1w REG 8,1 148 181517 /home/me/test/while-count

kill -9 17653

Now try running the script again. It works now.