Re: cron error - date command
On Sat, Feb 01, 2020 at 09:42:25PM +1100, Keith Bainbridge wrote:
> Good evening All
>
> I have a niggling problem.Any suggestions, please?
>
> If I run
> echo `date +%d%b%Y` >> /home/keith/.bash_history
> in a xterm (Mate I think always), I get the expected result: a line in
> .bash_history reads
>
> 2020Feb01
> followed by
> echo `date +%Y%b%d` >> /home/keith/.bash_history
>
>
>
> I have this line as a cron-job, and constantly get error messages:
>
> /bin/bash: -c: line 0: unexpected EOF while looking for matching ``'
> /bin/bash: -c: line 1: syntax error: unexpected end of file
>
> and no output to .bash_history
>
>
Hi Keith,
I'm not sure what problem you are trying to solve, but let me suggest
that you instead set the HISTTIMEFORMAT environment variable. For
example
$ export HISTTIMEFORMAT="%Y%b%d "
$ history | tail
25567 2020Jan31 git log --oneline --graph --branches
25568 2020Jan31 gbp buildpackage --git-tag --git-tag-only
25569 2020Jan31 git log --oneline --graph --branches
25570 2020Jan31 for base in /var/cache/pbuilder/base-* ; do sudo cowbuilder --update --basepath ${base} ; done
25571 2020Jan31 sudo debootstrap --variant=buildd sid /srv/chroot/sid/ http://ftp.us.debian.org/debian/
25572 2020Jan31 schroot -c source:sid -u root -d tmp -- sh -c 'apt-get update && apt-get dist-upgrade -y && apt-get clean'
25573 2020Jan31 sysctl -n hw.logicalcpu
25574 2020Jan31 grep -c ^processor /proc/cpuinfo
25575 2020Jan31 export HISTTIMEFORMAT="%Y%b%d "
25576 2020Jan31 history | tail
Regards,
-Roberto
--
Roberto C. Sánchez
Reply to: