1

I have this example script:

<?php
    $time = time();
    shell_exec('nohup sleep 30 2>/tmp/test >/tmp/test &');
    $time2 = time();
    echo $time2 - $time;
?>

when I run it for the first time it show immediately 0 , but when I run it for the second time it wait for the sleep command to finish the it shows the 0. what should i do to make it run immediately without waiting for the sleep command ?

Prasanna
  • 779
  • 5
  • 13
elarichi.y
  • 57
  • 8
  • I would guess that the file is locked. So if you want to run it multiple times simultaneously, you should use different / random file names. – jeroen May 26 '15 at 14:30
  • http://stackoverflow.com/questions/9100872/run-php-script-on-background-in-php-with-nohup-cli – Kyto May 26 '15 at 15:14
  • Do you want to do a "sleep" command or a "background" command? – Kyto May 26 '15 at 15:14

0 Answers0