Page 1 of 1

Crontab entry help (probably syntax issue)

Posted: 2014/10/16 20:13:47
by Canary Wundaboy
Hi All,

I'm new to linux, I've been managing to work out all of the issues I've run into so far with some common sense and a fair amount of Google but I'm a bit stuck right now.
I have a command that works fine when I run it in terminal, but doesn't work at all when inserted into crontab -e. I think it's a syntax thing:

Crontab -e file:
#Environment PATH for crontab
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:

#Code to test cron is working (beep every minute)
#* * * * * echo -e "BEEEP\n" >/dev/pts/0

#Hourly job to create empty .txt file in /home/paul/datefiles
0 * * * * touch /home/paul/datefiles/$(date +%F-%T).txt

The command that isn't working:
touch /home/paul/datefiles/$(date +%F-%T).txt

What /var/log/cron shows:
Oct 16 21:00:01 localhost CROND[8722]: (paul) CMD (touch /home/paul/datefiles/$(date +)

I'm assuming it's the bit highlighted in red that isn't working, but not sure how it works when entered in terminal but not in crontab.
Can someone please assist?

Thanks in advance!

Re: Crontab entry help (probably syntax issue)

Posted: 2014/10/16 22:32:26
by jrawle
Try adding:

Code: Select all

>> /tmp/cron.log 2>&1
to the end of your crontab line. That will log everything including errors to a file, which may give a clue as to why it isn't working.

Re: Crontab entry help (probably syntax issue)

Posted: 2014/10/16 22:37:03
by gerald_clark
man 5 crontab
and note the special significance of the '%' character.