CrisThompsonUK
asked on
PHP As Batch Process...
Hi,
A bit of a speculative question here;
In a week or so, I need to start building PHP processes that need to run on my server and do daily, weekly and monthly tasks.
They will be started, and log start, end times and progress into a MySQL table.
Anyone got any pointers? Never done this before with PHP.
Thanks,
Cris.
A bit of a speculative question here;
In a week or so, I need to start building PHP processes that need to run on my server and do daily, weekly and monthly tasks.
They will be started, and log start, end times and progress into a MySQL table.
Anyone got any pointers? Never done this before with PHP.
Thanks,
Cris.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points. This article may be helpful in planning asynchronous or long-running scripts.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html
You can make POST-method requests to start PHP scripts. The "screen" script will be initiated by a client GET-method request, just like any web page. This script, in turn, will make POST requests to start the long-running scripts. The long-running scripts may want to use ignore_user_abort() to allow them to run asynchronously. See also. Since these scripts are started via POST and do not have browser output, you'll probably want some way to access diagnostic messages. The easiest way to start a script with a POST request is probably to use fsockopen() or the cURL library.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html
You can make POST-method requests to start PHP scripts. The "screen" script will be initiated by a client GET-method request, just like any web page. This script, in turn, will make POST requests to start the long-running scripts. The long-running scripts may want to use ignore_user_abort() to allow them to run asynchronously. See also. Since these scripts are started via POST and do not have browser output, you'll probably want some way to access diagnostic messages. The easiest way to start a script with a POST request is probably to use fsockopen() or the cURL library.
ASKER
thanks, I'll open a new question for this...
ASKER
that's about what I was thinking.
After 10 years of making website backends, I'm currently developing a whole backend system for a company with lots of procedure calls and batch processes..
It's like my old days software engineering, and it's coming back!
I do have a further question:
I have a php script called from a screen to update some stuff, but one of the tasks it needs to do will take about 15 seconds to complete. I don't want to make the user wait for this, so how can I make my php do it's thang, but also fire off another php script to do the other longer thing.
About to turn to google...