running commands sequentially in background with exec($commands_in_background)
| From: | Dasdan | Date: | Fri, 28 Jul 2006 10:45:08 +0000 |
| Subject: | running commands sequentially in background with exec($commands_in_background) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-239848@lists.php.net to get a copy of this message | ||
I want to execute a couple of linux commands from a php script 'sequentially in background'.
I want to run them in background so the php script doesn't hang while the linux commands are running.
example:
first i create a lock file with php
$lockfile_path : /home/web/...blablabla.../test.tar.bz2_Lock.txt
the I execute the following command from my php script:
exec("du -a ~/ 2>&1 > /home/web/...blablabla.../backupFSlog.txt ;
sleep 10 >/dev/null 1>/dev/null 2>/dev/null ; rm -f $lockfile_path
/dev/null 1>/dev/null 2>/dev/null &);problem: the php script hangs for 10 seconds (sleep), what is not what I want I've read a lot of sugestions but I can't get it to work. When I execute the commands one by one, it works in background, but when I want to run them 'sequentially in background', the php script hangs They need to run sequentially because the $lockfile_path may only be deleted when all the other commands are executed Some advice please? -- http://www.dasdan.be