[TriLUG] dayname in cron ?

Brad Jorsch anomie at users.sourceforge.net
Thu Feb 1 21:24:58 EST 2007


On Thu, Feb 01, 2007 at 09:05:14PM -0500, S B wrote:
> 
>   */1  *   *   *   *     echo hello >/var/test-$(date +"%a").txt  

According to the crontab file manpage ("man 5 crontab"), '%' is
translated to a newline and everything after the first % is passed as
standard input. So your command there is being interpreted as something
like
  echo 'a").txt' | sh -c 'echo hello >/var/test-$(date +"'

This worked for me when I put it in my crontab:
  */1  *   *   *   *     echo hello >/tmp/test2-$(date +"\%a").txt





More information about the TriLUG mailing list