Crontab entry help (probably syntax issue)

General support questions
Post Reply
Canary Wundaboy
Posts: 1
Joined: 2014/10/16 20:07:22

Crontab entry help (probably syntax issue)

Post by Canary Wundaboy » 2014/10/16 20:13:47

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!

jrawle
Posts: 22
Joined: 2009/04/03 13:02:03
Contact:

Re: Crontab entry help (probably syntax issue)

Post by jrawle » 2014/10/16 22:32:26

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.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Crontab entry help (probably syntax issue)

Post by gerald_clark » 2014/10/16 22:37:03

man 5 crontab
and note the special significance of the '%' character.

Post Reply

Return to “CentOS 7 - General Support”