in reply to How to redirect the output of system call

To redirect output from a call to system, use shell level redirection:
system('your_command --with options > /other/file');

To keep a CGI script running after the connection quits, use fork and close or re-open STDOUT and STDERR. See also Watching long processes through CGI.