Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple php script

echo $i;

Which I run from the command line

php myfile.php &

I would expect I can do other things in the command line, even before the scripts ends.
I do get a prompt, but when I press the enter I get [1]+ Stopped php myfile.php

share|improve this question

This is expected if your terminal has the tostop option enabled. When that is set, any background process that tries to output to the terminal receives the SIGTTOU signal, and that signal's default handler stops the process. (This is done so that output from background processes doesn't mess up your terminal.)

You can disable this feature by running stty -tostop, in the same terminal.

Your current situation:

$ stty tostop
$ php ./t.php &
[1] 6484
[1]+  Stopped                 php ./t.php
$ # no messing up of the terminal, process stopped
$ fg
php ./t.php

Disable that feature:

$ stty -tostop
$ php ./t.php &
[1] 6481
$ # 01an2d 3now 45 6it m7esses 8up 9my term!
share|improve this answer
did the stty -tostop (with and without sudo) still not workin, same message – Itay Moav -Malimovka Jan 4 '12 at 19:40
this needs to be in the same terminal you run php from, just as in the examples I posted. – Mat Jan 4 '12 at 19:42
It is in the same terminal. It seems like an issue of Ubuntu. If I do the & from inside a php file it works fine. – Itay Moav -Malimovka Jan 4 '12 at 20:00
What do you mean by "do the & from inside the php file"? – Mat Jan 4 '12 at 20:01
inside the php I do [backtik]php t.php>log &[backtik] This, in php, runs the command inside the backtiks at the shell level (Did I say it right?). If I do that, the script runs async i.e. I can use the command line and the t.php runs in the background and outputs into log – Itay Moav -Malimovka Jan 5 '12 at 1:17

There's probably a better solution, but for me, on Ubuntu, it works if you run it in the foreground and suspend it with Ctrl-Z, and then background it with bg:

$ php myfile.php 
[4]+  Stopped                 php myfile.php
$ bg
[4]+ php myfile.php &
$ 2#3 it4 mess5es up 6my 7term8in9al too!
[4]   Done                    php myfile.php
share|improve this answer
which Ubuntu version are you using? – Itay Moav -Malimovka Jan 5 '12 at 13:46
Ubuntu 11.04 -- – mkopala Jan 5 '12 at 23:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.