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 ?

3
  • 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. Commented May 26, 2015 at 14:30
  • stackoverflow.com/questions/9100872/… Commented May 26, 2015 at 15:14
  • Do you want to do a "sleep" command or a "background" command? Commented May 26, 2015 at 15:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.