【转】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.

时间: 2024-08-05 12:45:50

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

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

在执行一个shell脚本时,遇到了"-bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy"错误提示,如下所示: [[email protected] bin]$ ./killSession.sh      -bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy 此时只需要在#!/bin/bash,加一空格#! /bin/bas

linux下shell脚本执行方法及exec和source命令

exec和source都属于bash内部命令(builtins commands),在bash下输入man exec或man source可以查看所有的内部命令信息. bash shell的命令分为两类:外部命令和内部命令.外部命令是通过系统调用或独立的程序实现的,如sed.awk等等.内部命令是由特殊的文件格式(.def)所实现,如cd.history.exec等等. 在说明exe和source的区别之前,先说明一下fork的概念. fork是linux的系统调用,用来创建子进程(child

shell脚本执行及配置文件

linux之shell脚本执行及配置文件 bash脚本执行方法:     1 解释器直接运行         /usr/bin/bash bash FOO.sh     2 使用路径运行脚本(需要有x权限)         chmod +x FOO.sh         /PATH/TO/FOO.sh     3 使用.或source命令执行脚本         . /PATH/TO/FOO.sh         source /PATH/TO/FOO.sh     1,2执行方法和3执行方法的

shell脚本执行冲突事件-ssh&while

今天发现一个问题: 先看下脚本内容: [email protected]/0 # cat !$ cat /tmp/test_nginx ls *.txt | tr ' ' '\n' | while read line do  echo $line if [ 'yes' == 'yes' ] then ssh  192.168.109.10 "echo 'yes'" else ssh 192.168.109.10 "echo 'no'" fi done 上面脚本很简单

执行shell脚本报错 '\357\273\277': command not found 解决办法

1,删除BOM,在vi下面执行下面的命令即可 :set nobomb 2,原因: 所谓BOM,全称是Byte Order Mark,它是一个Unicode字符,通常出现在文本的开头,用来标识字节序(Big/Little Endian),除此以外还可以标识编码(UTF-8/16/32) 对于UTF-8/16/32而言,它们名字中的8/16/32指的是编码单位是多少位的,也就是说,它们的编码单位分别是8/16/32位,换算成字节就是1/2/4字节,如果是多字节,就要牵扯到字节序,UTF-8以单字节为

shell 脚本执行和基础知识

当我们给予shell脚本执行的权限后,就可以测试程序了,假设shell脚本文件为hello.sh放在/root目录下.下面介绍几种在终端执行shell脚本的方法:1.切换到shell脚本所在的目录,执行: [[email protected] home]# cd /root/[[email protected] ~]# ./hello.shhello guys!welcome to my Blog:linuxboy.org! 2.以绝对路径的方式执行: [[email protected] ~]

Shell脚本执行hive语句 | hive以日期建立分区表 | linux schedule程序

#!/bin/bash source /etc/profile; ################################################## # Author: ouyangyewei # # # # Content: Combineorder Algorithm # ################################################## # change workspace to here cd / cd /home/deploy/rec

shell脚本执行mysql语句出现的问题

shell脚本执行mysql语句出现的问题,问群里的大牛的到解答,是单引号问题,改成双引号即可 #小提示(对本主题没什么关联):ubuntu目前使用的是dash,导致一些for(()函数无法正常执行, sudo dpkg-reconfigure  dash 选择NO,就改会bash了 一.脚本内容如下: #/bin/bash hostname='192.168.2.52' port=3306 username='root' password='123456' #dbname='' #-----s

shell脚本执行方式

方法一:切换到shell脚本所在的目录(此时,称为工作目录)执行shell脚本: cd /data/shell ./hello.sh ./的意思是说在当前的工作目录下执行hello.sh.如果不加上./,bash可能会响应找到不到hello.sh的错误信息.因为目前的工作目录(/data/shell)可能不在执行程序默认的搜索路径之列,也就是说,不在环境变量PASH的内容之中.查看PATH的内容可用 echo $PASH 命令.现在的/data/shell就不在环境变量PASH中的,所以必须加上