PDA

View Full Version : Running shell scripts from PHP as background processes, any advantage?



markowe
10-14-2009, 05:47 AM
Are there any advantages or disadvantages to running certain tasks in the shell but via PHP? I am currently getting a large remote file (200mb) by executing "wget http://bigfilelocation > dummypipefile.txt &" from PHP (because I want control over the process from PHP, not a shell script). The dummy pipe and the '&' ensure that it is run as a background shell process which releases my PHP thread straightaway and prevents a timeout. Does that seem a reasonable approach?

What if I extended this to also running some large MYSQL operations in the same way, in the shell as background processes? Would I save overhead that way, does the shell distribute processor time any better than tying up PHP/Apache (i.e. I want to avoid getting "throttled") or is there no point in doing this? I was thinking of having my PHP execute a LOAD DATA INFILE and then go away and do other stuff until it's finished.