Note, for some systems a %
is special in a crontab: from crontab(5) on my system
The "sixth" field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or a "%" character, will be executed by /bin/sh or by the shell
specified in the SHELL variable of the cronfile. A "%" character in the command, unless escaped
with a backslash (\), will be changed into newline characters, and all data after the first % will
be sent to the command as standard input.
I strongly recommend using the date format %Y-%m-%d
-- not only is it a standard, it sorts the same lexically and chronologically. Some strftime implementations have a shorthand for it: %F
See if your system has a ts
command
cd /dir && git pull origin master 2>&1 | ts "\%F \%T" >> /var/log/crond/site.log
To get "real-time" timestamps, you might have to unbuffer the command: (starting to get really ugly)
cd /dir && stdbuf -oL sh -c 'git pull origin master 2>&1' | ts "\%F \%T" >> /var/log/crond/site.log
%
probably. – glenn jackman Jan 07 '15 at 22:40