Bash等待信号结束
逻辑:
但是,bash启动A.php并等待......
#ps -aux
root 27647 0.0 0.0 13336 652 pts/0 S+ 11:36 0:00 /bin/bash /var/www/scripts/bgluncher.sh -c php /var/scripts/A.php -l /var/log/A.log -p B.php
root 27648 0.7 0.2 332396 87544 pts/0 S+ 11:36 0:02 php /var/scripts/A.php
bash中:
#!/bin/bash
COMM=''
POST_CMD=''
LOG=0
while getopts ":l:c:p:" arg; do
case "${arg}" in
c)
COMM=${OPTARG}
;;
l)
LOG=1
LOG_File=${OPTARG}
;;
p)
POST_CMD=${OPTARG}
;;
esac
done
if [ -z "${COMM}" ]; then
echo `date` ' ERROR: [bgluncher.sh] -c argument is empty ' >> ${LOG_File}
else
if [ ${LOG} -eq 1 ] ; then
${COMM} >> ${LOG_File} && ${POST_CMD} || ${POST_CMD}/error=$2 &
echo $!
else
${COMM} >> /dev/null && ${POST_CMD} || ${POST_CMD}/error=$2 &
echo $!
fi
fi
exit
成为或不成为,我犯了什么错误?
答案 0 :(得分:0)
$2
是第二个命令行参数(php),而不是COMM的退出代码,为此使用$?
。
你可能想要一个空格而不是$ {POST_CMD}之后; B.php error=2
而不是B.php/error=2