[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Adding Date & Time to a script's output log



On Thu, 01 Jun 2017, SUZANNE COBB wrote:
> I try to capture the date and time into a variable named 'dt':
> 
> dt= $(date '+%d/%m/%Y %H:%M:%S');
> 
> echo "%dt" "Changed ${DYN_DOMAIN} from ${registeredIp} to ${externalIp}" >> /var/log/updated-ddns.log

I think you want echo "$dt" "Cha[...].

% is generally only used to refer to a job specification.

Finally, you're probably better off using the "logger" command in
util-linux to write to log files, not appending to a file directly.

-- 
Don Armstrong                      https://www.donarmstrong.com

"Do you need [...] [t]ools? Stuff?"
"Our opponent is an alien starship packed with atomic bombs. [...] We
have a protractor."
 -- Neal Stephenson _Anathem_ p320


Reply to: