program exec killed after php restart (or stop)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nathanj
Forum Newbie
Posts: 2
Joined: Sun Dec 17, 2006 9:44 pm

program exec killed after php restart (or stop)

Post by nathanj »

I have been trying to write a script/interface for system updates for a linux distro called openfiler. This page is used to update the packages used by the disto such as samba, bind, tar, ... basically all the packages used in linux. The problem with the script is that if it trys to update its own package, the update process attempts to restart the service (the php service) and the process dies. In other words any thing I start with the script gets killed when the php service is stopped/restarted.

I need to start a command with exec() or the like and have it continue after the service openfiler (or php) is stopped.

Right now, just for a debugging test, I am trying to run exec("sleep 100 > /dev/null 2>&1 &"). The program runs fine, and the sleep command continues after the script like it should. The only problem is that if I stop the service openfiler, everything that was started on the php page stops immediately.

Is there any way to continue the execution after stopping the service/program?

Thanks,
Nathan Jones
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What about using cron and the command line version of php?
nathanj
Forum Newbie
Posts: 2
Joined: Sun Dec 17, 2006 9:44 pm

Post by nathanj »

I guess i could use cron, I was just trying to avoid it. I'd probalby write a bash script if I have to offload this to a second script, that way I don't have to worry about php killing the second script that the cron would start.

I'd still like to see if there is another option. Is there not any way to turn the executed process/script into a standalone process? I don't know if I'm trying to kill the heredity of the process or something else.

I was looking at 'ps -axf' output and it doesn't seem to provide anything useful to me:
1922 ? Ss 0:00 /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2114 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2115 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2116 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2117 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2118 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2144 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2145 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
2146 ? S 0:00 \_ /opt/openfiler/sbin/openfiler -f /opt/openfiler/etc/httpd/conf/httpd.conf
1929 ? Ss 0:00 crond
1949 ? Ss 0:00 winbindd
1952 ? S 0:00 \_ winbindd
1957 ? Ss 0:00 /usr/sbin/atd
1968 tty1 Ss+ 0:00 /sbin/mingetty tty1
1969 tty2 Ss+ 0:00 /sbin/mingetty tty2
1970 tty3 Ss+ 0:00 /sbin/mingetty tty3
1971 tty4 Ss+ 0:00 /sbin/mingetty tty4
1972 tty5 Ss+ 0:00 /sbin/mingetty tty5
1973 tty6 Ss+ 0:00 /sbin/mingetty tty6
2284 ? S 0:00 sleep 100

I started the last line and I can't see where it is connected to the above openfilers processes.

Thanks,
Nathan Jones
Post Reply