Ok, here it is:
I wonder if there is any way to get the process-id of a backgroundprocess thrown in a php-script using exec.
So that I, on every 'some'-request check if a backgroundscript is running and if not make sure it does start running.
Background:
I'm building an alpha of a webgame which will be built in the following way:
-A deamon (written i php, since my host wont allow C-executables) that does things and updates a Db.
-A server that handles the user requests
-A Db to store the current status of a lot of things, and also stores tasks for the deamon to do,
-A web-app (also written in php) that queries the Db for data and also writes tasks for the deamon in the Db.
/Tomas
controlling a php-deamon, sort of
Moderator: General Moderators
controlling a php-deamon, sort of
Last edited by piuga on Thu Jan 09, 2003 6:12 am, edited 1 time in total.
you can check the output of
Code: Select all
exec('ps -ax | grep "whatYoureLookingFor"', $output);ok..?
Ok, and what does it tell me?
Is it possible to get the process-id when I've started the process, save it in a Db and then check for it?
Sorry if this doesn't make sense, but I'm a total linux/unix newbie.
Is it possible to get the process-id when I've started the process, save it in a Db and then check for it?
Sorry if this doesn't make sense, but I'm a total linux/unix newbie.
It would be the name of the process you are trying to find, example:
that's all there is too it...Enjoy...
Code: Select all
If you are trying to find the MySQL Daemon you would put in:
ps ax mysqldif you have invoked another php script in background settting "WhatYourLookingFor" to the script's name should return something like 12678 /usr/bin/php -f /path/scriptname if the script is still running. If not $output should be empty.
If you still need to extract the pid you might do so with
If you still need to extract the pid you might do so with
Code: Select all
exec('ps -ax | grep "whatYoureLookingFor"', $output);
if (count($output) > 0)
{
$pid = explode(' ', $output[0]);
$pid = $pid[0];
...Thanks alot!
Thanks, now I get it!