开发者

How to run a CGI script in another process through Apache

开发者 https://www.devze.com 2023-03-05 09:19 出处:网络
I have a CGI script th开发者_如何学编程at executes a very intensive Java application: start.cgi

I have a CGI script th开发者_如何学编程at executes a very intensive Java application:

start.cgi

#!/bin/sh

cd /var/server/; screen -d -m java -Xmx800M -Xms800M -jar jarfile.jar > /dev/null 2>&1 &

echo "Server command executed.";

This executes just fine by navigating to it in an internet browser and through an SSH session.

But when run by navigating to it with an internet browser, it seems to run under the apache process... Output of top:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

7651 apache 24 0 1149m 38m 9012 S 0.0 2.5 0:01.42 java

When run via an SSH session top outputs:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

7685 root 23 0 1163m 205m 9432 S 12.3 13.6 0:06.03 java

I believe the CGI script is running under the apache process...

Can someone please point out what I have done wrong or point me in the right direction?

Thanks!

Justin


You may have to chmod your script file to set the uid as root - but I'd have to say that that is not a great idea. Is there a problem in the job running as apache rather than root? Surely the only reason that it runs as root from an ssh session is because you have logged in as root?

0

精彩评论

暂无评论...
验证码 换一张
取 消