[PLUG] Adding timestamp to log file entry

Robert Citek robert.citek at gmail.com
Thu Sep 25 17:07:47 UTC 2014


Hello Rich,

Assuming that is in a bash script, you can do something like this:

    echo $(date +%FT%T%:z) ${NEWIP} >> "/home/rshepard/getiplog"

See the man page for date for various formatting strings.

Regards,
- Robert

On Thu, Sep 25, 2014 at 9:39 AM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
>    Cron runs a shell script to see if Frontier has changed my IP address. If
> the address has changed the new one is appended to a log file:
>
>                    echo $NEWIP >> "/home/rshepard/getiplog"
>
>    How do I add a timestamp to that file along with the new IP address? Can I
> do something like 'echo $timestamp $NEWIP ...'?
>
> Rich
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug



More information about the PLUG mailing list