Link to home
Start Free TrialLog in
Avatar of skij
skijFlag for Canada

asked on

PHP: Getting the PID of a process running in the background

This PHP code runs the $cmd in the background.   The response is written to the file $outputfile and the pid of the process is written to $pidfile.
exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));

Open in new window

Instead of writing the $pidfile to a file, how can I access it in the PHP script?  Can I access it as a variable instead of writing the result to a file?
SOLUTION
Avatar of Uros Gaber
Uros Gaber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial