Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI background execution

Status
Not open for further replies.
Apr 28, 2002
1
AU
G'day,

I'm trying to use Apache (1.3/RedHat 7.2) to spawn background processes which I would like to continue executing even after httpd has terminated. I'm scripting using bash.... I've managed to close stdout so that Apache happily returns & leaves the process running, but when I stop Apache all spawned processes die a nasty death. I'm doing this as a Java/CORBA application management & self-service deployment type of thing.

I need to capture the stdout of the target processes, so my script creates another script which launches the real process, with stdout redirected for the java process, but stdout/stderr and stdin closed for the subshell, as can be seen below.

Also, Apache seems to periodically "clean up" my processes while I'm not looking, and I have no idea why.

Am I crazy? Is this worth persuing?

Thanks,

~NJ!~

-------------

* echo "#!/bin/bash" > $DODGY_ROOT/projects/$project/tmp/$component.run
* echo "$cmdline > $DODGY_ROOT/projects/$project/log/$component 2>&1 &" >> $DODGY_ROOT/projects/$project/tmp/$component.run
* echo "echo \$! > $DODGY_ROOT/projects/$project/tmp/$component.pid" >> $DODGY_ROOT/projects/$project/tmp/$component.run
* echo "echo \$!:$component >> $DODGY_ROOT/projects/$project/tmp/pidlist" >> $DODGY_ROOT/projects/$project/tmp/$component.run
* chmod 777 $DODGY_ROOT/projects/$project/tmp/$component.run
* if [ -f $DODGY_ROOT/projects/$project/log/$component ] ; then
* {
* rm $DODGY_ROOT/projects/$project/log/$component
* }
* fi
* echo &quot; Executing...<br>&quot;
* $DODGY_ROOT/projects/$project/tmp/$component.run 2>&- 1>&- 0<&- &
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top