Advertisement
Guest User

Untitled

a guest
Feb 1st, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // nohup_test.php:
  2.  
  3. // a very long running process
  4. $command = 'tail -f /dev/null';
  5. exec("nohup $command >/dev/null 2>/dev/null &"); // here we go
  6. printf('run command: %s'.PHP_EOL, $command);
  7. echo 'Continuing to execute the rest of this script instructions'.PHP_EOL;
  8.  
  9. for ($x=1000000;$x-->0;) {
  10. for ($y=1000000;$y-->0;) {
  11. //this is so long, so I can do ps auwx | grep php while it's running and see whether $command run in separate process
  12. }
  13. }
  14.  
  15. $ php nohup_test.php
  16. run command: tail -f /dev/null
  17. Continuing to execute the rest of this script instructions
  18.  
  19. $ ps auwx | grep tail
  20. nemoden 3397 0.0 0.0 3252 636 pts/8 S+ 18:41 0:00 tail -f /dev/null
  21. $ ps auwx | grep php
  22. nemoden 3394 82.0 0.2 31208 6804 pts/8 R+ 18:41 0:04 php nohup_test.php
  23.  
  24. passthru("/path/to/program args >> /path/to/logfile 2>&1 &");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement