Page 1 of 1

Problem with CLI script ran in background

Posted: Fri Oct 30, 2009 1:26 am
by vagrand
Hi. I have strange problem. I install Ubuntu as my desktop os. Also i install php with CLI support (from apt):

> php -v
PHP 5.2.6-2ubuntu4.3 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21 2009 20:36:27)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans

I try to run next simple command:

> /usr/bin/php -r 'echo "works";' > test.txt &

Command has to run in background and create file test.txt and write into it string "works", but command only create empty file and when I check status of process:

> > ps ax | grep php
4581 pts/0 T 0:00 /usr/bin/php -r echo "works";
4600 pts/1 S+ 0:00 grep php

I get flag "T" for it. As i understood it means terminated, but I don't understud why.
If run this command with out "&", like this:

> /usr/bin/php -r 'echo "works";' > test.txt

then all works greate. I known that PHP CLI scripts can be run in background, I ran them many times in ALT Linux. May be my php in Ubuntu has some different settings, but I don't known which.

If somebody known the reason please advise.