In the need to add custom logging messages to ppp.log, I see that the date and time are missing when outputting the command to >> /var/log/ppp.log
. Other pppd related messages in ppp.log are prepended with a timestamp format that is similar to: "Sat Apr 9 17:18:02 2016 :
". My goal is to output this exact date time format in a Mavericks shell script
I know that other log files have different date/time timestamps. I want to re-create the format as used in ppp.log.
Regression
This Mac OS X 10.9 environment is configured with a dutch language locale. Therefore $ echo $(date '+%a')
returns "za
" instead of the desired "Sat
". That is the part that can be fixed by export LC_TIME="C"
or export LC_TIME="POSIX"
. I have tried to read the date
and pppd
man page. However then there is still the abbreviated alphabetic timezone name CEST (the %Z
part in $ date +%Z
) in the output "Sat Apr 9 18:12:12 CEST 2016
".
I know I can create the format using all the different $ date
format codes, like %a %b %e
etcetera. Though I guess there is a shorter way, isn't there?