[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: cron error - date command



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
>
>
> Thanks for your suggests

  it looks questionable to me just in that you
may be writing to that file at the same time as
you when you're doing something else that is also
trying to write to that file.

  if you want a log put it in /var/log/<somefilename>.log 
using the rsyslog or in the journal that system-d 
uses via the logging interfaces.

  i haven't looked at cron jobs in ages.

  for putting something into the bash history from the
command line use the history -s command so for your
above idea i would use:

$ history -s `date +%d%b%Y`


  songbird


Reply to: