1

First, I write a simple PHP script

<?php
while(true)
  {
    echo 'hey'.PHP_EOL;
    sleep(1);
  }

Then I run it like:

php test.php &

Obviously goes into background, but keeps running and prints hey repeatedly.

Now run it like:

php test.php

and hit Ctrl+Z while it is running. It goes into background but stops running.

Why stop running? How to keep it running while it goes into background? Think of time when you run something and in the middle of it, you realize you should do something real quick.

4

Ctrl-z sends SIGTSTP to the process, suspending it. To background it properly you need to run bg afterwards.

  • 1
    Thanks! Very sad it did not come to my mind. Seems like an obvious thing :) – vfsoraki Sep 4 '14 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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