Run a cgi shell script in background
I've a cgi shell script like this #!/bin/sh # show the page echo Content-type: text/html echo echo "<html><b>Hello world!</b></html>" # the task I want to do in background sleep 100 echo $(date) >> log I want to page to show after the last echo , not at the end of the execution of the script. I've tried putting the code in another file and execute it like this ./background.sh & . It works in console but not in the browser. I use lighttpd Aaron Digulla Close stdout with exec >&- before you execute your long-running or background task. Maybe you'll also have to close stderr. That would be exec >