1

I am just wondering (since I do not have my unix platform to test) if I executed a multi command line via the shell_exec() on PHP, am I already safe to close the browser without waiting for it to finish?

Because as far as I know, wget will keep downloading the file (that's why it is favorable than cURL for unstable and slow network).

For now I am very worried that my downloads will be interrupted and cross checking each file whether it was completed or not will arise more work.

Look at this multiline command my PHP is generating: As of now, it waits for downloads to finish wget "hxxp:// - 01 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 01 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 02 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 02 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 03 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 03 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 04 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 04 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1

then echo the output via:

$output = shell_exec($exec);
echo $exec.'<br /><pre>'.$output.'</pre>';`

I am willing to drop the 2 lines above as long as I know that the multiline command will be executed in the background even I close the PHP script.

Hope somebody can give their insight or suggestion.

Thanks!

The Wolf
  • 205
  • 2
  • 15
  • possible duplicate : http://stackoverflow.com/questions/1019867/is-there-a-way-to-use-shell-exec-without-waiting-for-the-command-to-complete – alfallouji Mar 09 '15 at 11:53

1 Answers1

1

It's as simple as adding a & to the end of your command string, to run wget in the background, and not have PHP wait for the command to exit. However, you won't be able to get the output from the command, seeing as it might still be running when the script finishes.

Elias Van Ootegem
  • 67,812
  • 9
  • 101
  • 138
  • I tried, it though I can't assure if the result would be favorable, will check if wget is really successful even after closing the browser. Thanks! – The Wolf Mar 09 '15 at 12:16