Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Making a log?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Making a log?
Authored by: jpryor68 on Mar 13, '03 11:30:59AM
How do I make a log with the info given by this script?
% ./scriptname > battery.log
Puts the output of the script into the file, but how do I append new data to the end of the file and maybe add a timestamp? Can it be done in a single command or would it have to be build into the script itself?

This appends a timestamp and scriptname's output to a log file:
% date;scriptname >> logfile.log

[ Reply to This | # ]

Shell Scripting
Authored by: ktohg on Mar 13, '03 07:26:24PM

Don't wish to intrude but this will not work as expected

The semi coloen is a command delimeter so the date command will have default input and output where as the other command will have output redirected to the log file.

To accomplish what you wish you can do it two ways. (The first I belive may not be supported in every shell.

% (date ; scriptname) >> logfile.log

or

% date >> logfile.log ; scriptname >> logfile.log

[ Reply to This | # ]