Re: Adding Date & Time to a script's output log
On Thu, Jun 01, 2017 at 02:26:00PM +0000, SUZANNE COBB wrote:
> I try to capture the date and time into a variable named 'dt':
>
> dt= $(date '+%d/%m/%Y %H:%M:%S');
>
> [please see there is a space between = and $, and between Y and %]
The space after = is wrong. It will not work. You must remove it.
The ; at the end of the line is optional. You may remove that too.
> echo "%dt" "Changed ${DYN_DOMAIN} from ${registeredIp} to ${externalIp}" >> /var/log/updated-ddns.log
%dt is not how you reference a shell variable. It should be $dt. Of
course, that won't do anything currently, because your dt variable has
not been set, because your assignment command was wrong.
Reply to: