[root@localhost ansible]# cat filebeat_stop.sh
#!/bin/bash
pid=`ps -ef|grep filebeat|grep "\./filebeat"|grep "filebeat.yml"|awk '{print $2}'`
echo $pid
kill -9 $pid
[root@localhost ansible]# sh filebeat_stop.sh 
4272
: arguments must be process or job IDs

单独执行“filebeat_stop.sh”脚本中的每一个语句没有问题,可是执行这个脚本却总报“arguments must be process or job IDs”错误。将文件改成可执行文件,在用./filebeat_stop.sh命令执行时报下面的错误。

[root@localhost ansible]# ./filebeat_stop.sh 
bash: ./filebeat_stop.sh: /bin/bash^M: bad interpreter: No such file or directory

立刻明白很有可能跟文件的格式有关系。

在解决掉这个问题“/bin/bash^M: bad interpreter: No such file or directory”后,可以正常执行这个“filebeat_stop.sh”文件了。

使用这个命令“sed -i "s/\r//" filename”,将文件格式修改为unix格式。

具体参考:https://blog.csdn/hxpjava1/article/details/79711710

昨天晚上困扰我的问题,今天上班后解决了,还是特别高兴的。 o(* ̄︶ ̄*)o

 

 

更多推荐

arguments must be process or job IDs