I have a python cgi script which looks like this:
Code:
logfile = open('xxxxxxxxx')
print "Content-Type: text/html\n\n"
.....
print ' <meta http-equiv="refresh" content="15;url=%s" />' % myURL
......
### after printing the page
os.system('python myfile.py &')
logfile.write('END OF SCRIPT')
logfile.close()