我正在尝试使用以下方法在后台进程在CGI shell脚本中运行时保持apache处于活动状态:
if [[ `ps -p $pid | wc -l` -gt 1 ]]
then
output="Program is running. Running time depends on the number of alternatively spliced proteins the submitted gene has. Results will be displayed here."
# echo -n "The program is running...\n"
echo "<html>"
echo "<head>"
echo "</head>"
echo "<body>"
echo "<table width="750" border="0" cellspacing="0" cellpadding="0">"
echo "<tr><td><img src=\"../../images/calc.gif\" align=\"absmiddle\"> <strong> $output </strong></td></tr>"
echo "</table>"
echo "</body>"
echo "</html>"
fi
&#34; $ pid&#34;包含进程ID。而且,&#34; calc.gif&#34;是一个gif,它在进程在后台运行时播放。 &#34;超时&#34;在我的&#34; httpd.conf&#34;文件设置为1200秒。有时脚本需要更长时间。我想通过使用上面的方法,我将保持apache活着,因为&#34; calc.gif&#34;正在玩,但它不起作用。
我知道我可以像这样使用while循环:
while kill -0 $pid
do
output="Program is running. Running time depends on the number of alternatively spliced proteins the submitted gene has. Results will be displayed here."
# echo -n "The program is running...\n"
echo "<html>"
echo "<head>"
echo "</head>"
echo "<body>"
echo "<table width="750" border="0" cellspacing="0" cellpadding="0">"
echo "<tr><td><img src=\"../../images/calc.gif\" align=\"absmiddle\"> <strong> $output </strong></td></tr>"
echo "</table>"
echo "</body>"
echo "</html>"
done
但是,这个解决方案的缺点是,它不断打印&#34; $ output&#34;多次在页面上排队。有人可以帮我知道如何在网页上避免这种多次打印?或者是一个替代解决方案,即使在程序超过&#34; timeout = 1200&#34;。
之后也能保持apache存活。