1
你好我正在尝试编写一个脚本来从命令行重新启动其他脚本。 用法应该是:重新启动脚本的脚本
重启someotherscript.sh
猫重启
#!/bin/bash
for pids in $(ps -ef | grep $1 | grep -v grep | awk '{print $2}')
do
kill -9 $pids
done
echo test
sleep 10
$1 &
输出为:
[email protected]:/scripts# restart pricealert.sh
Killed
[email protected]:
我重新启动脚本是杀害自己。 这里有什么问题?你能帮我么?
更好地使用'pgrep'甚至'pkill' –