open (STDOUT, ">$log_dir/$process.log") or exit 1; open (STDERR, ">&STDOUT") or exit 2; flock(STDOUT, LOCK_EX | LOCK_NB) or exit 3; truncate STDOUT, 0; #clear out STDOUT to start with a fresh log file. print "This is my log file.\n"; qx!someprogramtorun!; (do some more stuff) __DATA__ (what I see in the log file) This is my log file.