简体   繁体   中英

How to run a background PHP function with a POST variable using exec()?

exec('php convert.php >> convert.log &');

This is the sample code I found, but here's what I want to do.

  1. Run convert.php with 1 or more POST variables.

  2. Execute the function in the background in case the user leaves our website.

  3. Run multiple instances of convert.php in the background in case more than 1 user on the site at one time.

You do not need to execute the process in another process just to ensure that it continues to run. PHP has a built in feature for that.

ignore_user_abort() if true the current script will finish even if the user leaves while it's running.

Edit: as pointed out in comment you also need to disable time limit. Use set_time_limit(0)

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