简体   繁体   中英

Creating a Background PHP Process

I want to run a background php process(es) that does some work. I thought of two ways to doing this and I want to know which one is better and which is more possible using TideSDk

1) I've thought of using the Ti.Process.createProcess() in a js file to spawn off a process. The problem I faced with this is that there is no way to access the information recorded by this process without writing it to a file. Since Ti object is not available in a php script file i used the fopen() and fwrite() but these methods don't seem to be working. IS there any way I can access information from this process without trying to write to a file?

2) Another way I thought of doing this is to use javascript setInterval() and somehow connect it to the application and call the php function periodically. Is this possible to call a php function from a js file?

I want to maintain the js and php files separately and not have any inline scripting in the html files. Please let me know if I could do it with any of the above or in any different way

Either use a cron job . Or php exec() function.

re: option 1 - you can open a socket between your app and your process. Thats how I do it (in my case running bg ruby script).

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