How to I write to a log file all the output that is displaying on the screen? with time stamp.
thankx.
How to I write to a log file all the output that is displaying on the screen? with time stamp.
thankx.
if this runs from cron... just add a bit at the end " > logfile.out"
If this runs from a script you kick off add a line at the end of the script or add it at the end when you execute it from the command line...
./script.sh > logfile.out >2 logfile.err
That last bit I added puts all STDERR to a file as well.
thanks for you thoughts... but i want to embed the logging inside my script. For every line of output to the screen it will also append to a log file.
can i do something like this
LOG="logfile.txt"
printf "some text to scree" |& tee $LOG;
But the think is i would have to do that for every single line, i was wonderfing if there's a more effiecient way to log the whole execution of my script as opposed to line by line.
thanks.
You could have the script recursively run itself to a logfile...
example in csh:
if ( "${argv[1]}" != "~~" ) then
$\{0\} "~~" $\{argv[2-]\} >& <logfilename>
exit
endif