简体   繁体   中英

Launch shell command from PHP

Okay, this is going to be a very weird request/question.

There is a very long running PHP script that needs to be launched by the user (admin) who is not very technically adept. When running the script through apache, it throws a timeout (502 or 504 Bad Gateway).

Let's just assume that apache can't be configured to fix the timeout issues.

I want to create a button in the admin panel that sends an AJAX call to a PHP script on the server, that PHP script will act as a proxy of sorts to launch a shell command. The shell command will then execute the long running PHP script with certain arguments... but I don't want it to wait for the long running script to finish. The proxy PHP script can exit and return true/false based on if the shell command actually started (this part is optional).

Essentially, have PHP launch a shell command which launches a PHP script.

How can I pull something like this off?

Have you tried shell_exec . It worked for me... http://php.net/manual/en/function.shell-exec.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM