#!/usr/bin/perl -wT use strict; use CGI; if(fork()) { my $q = new CGI; print $q->header(); print $q->start_html(); ## print your html here print $q->end_html; } else { close STDIN; open(STDOUT, ">>/tmp/yourscript.log") || die "Can't redirect stdout"; open(STDERR, ">&STDOUT") || die "Can't dup stdout"; #you have to log warnings somewhere... select(STDERR); $| = 1; # so you can see what's appening with tail... select(STDOUT); $| = 1; #your email stuff here... }