Failing that, you could do something like this:
#!/usr/bin/perl -w use strict; use POSIX qw(strftime); my $start = time(); print "Started at ", (strftime "%a %b %e %H:%M:%S %Y", localtime($star +t)), "\n"; for (1 .. 5) { print "Logging some stuff...\n"; sleep 1; } my $end = time(); print "Ended at ", (strftime "%a %b %e %H:%M:%S %Y", localtime($end)), + "\n"; print "Total run time:", $end-$start, " seconds\n";
Which when run, gives you:
Started at Thu Dec 22 14:59:20 2005 Logging some stuff... Logging some stuff... Logging some stuff... Logging some stuff... Logging some stuff... Ended at Thu Dec 22 14:59:25 2005 Total run time:5 seconds
Then you simply redirect that to your logfile in the same way as you originally did.
In reply to Re^5: Append the timestamp before and after the data in the logfile
by McDarren
in thread Append the timestamp before and after the data in the logfile
by kulls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |