1

Can I run a PHP CGI script as a background process using exec() ?

3
  • How 'background' should it be? Asynchronous to the script? And under which operating system? Commented Mar 22, 2010 at 13:19
  • 2
    Running CGI in the background doesn't really make much sense. The CGI process has to run in the web server's foreground in order for any data to be sent to the client. Commented Mar 22, 2010 at 13:26
  • 1
    Plus, when running as CGI, the script is (or should be) subject to max_execution_time constraints which will prevent any long term running... You should really clarify what you need this for. Commented Mar 22, 2010 at 19:57

1 Answer 1

1

You could try it to start it as an linux background process using exec().

You could try this:

exec('/usr/bin/php /path/to/your/script.php &');

The '&' tell's linux to start this command in the background.

Note: You lose control over your executed script at that point and it may not work with all hosts (especially shared host envoirements).

Sign up to request clarification or add additional context in comments.

Comments

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.