I have a web crawling script I'd like to initiate from a PHP page. It needs to run in the background and be able to be stopped from the page as well. What's the best way of accomplishing this? I know I can run shell line commands from PHP, but it seems like they would not be suitable for something that needs to keep running?
Asked
Active
Viewed 133 times
1 Answers
1
Use PHP's exec()
in combination with bash's &
like this:
<?php
exec('myscript.py &');
The &
causes the process to run in the background.
http://php.net/manual/en/function.exec.php
Possible duplicate:
-
Hi i'm trying to use: /var/www/html/log/out.txt 2> /var/www$` but it doesn't seem to be working. None of the output is being written to the files and I can't see it with `jobs` – Dec 23 '14 at 05:45
-
Just had to chmod my logs directory - quick question, seems like its running but I'm not sure how to stop it? – Dec 23 '14 at 05:48