使用中遭遇的问题

1.shell脚本执行时报"bad interpreter: Text file busy"

解决方案一: 在#!/bin/bash#!后加一空格。如#! /bin/bash即可解决问题。

解决方法二:可能有其它进程访问这个shell脚本文件,可以通过lsof | grep SHELL_NAME来查看是否有其它进程正在访问该文件。如果有,使用kill -9 PID命令杀掉其它进程。代码演示如下:

$ /root/hello.sh        # 假设我们运行hello.sh时报错
-bash: /root/hello.sh: /bin/bash: bad interpreter: Text file busy
$ lsof | grep  hello.sh # 查看是否有其他进程在使用hello.sh文件
hello.sh 14442  root    0r      CHR     1,3     0t0    6083 /root/hello.sh
$ kill -9 14442            # 杀掉其他进程

2.运行root用户名登录

Last updated

Was this helpful?