1756128 Members
2957 Online
108841 Solutions
New Discussion юеВ

Re: crontab syntax

 
SOLVED
Go to solution
Deepak Seth_1
Regular Advisor

crontab syntax

1 12 * * * * /user/test/testme > /tmp/log.`date +"%m%d%H%M"` 2>&1

What is wrong with this ? I can't create a file with a date and time prefixed from the cron ?

What is the correct syntax .
6 REPLIES 6
John Poff
Honored Contributor

Re: crontab syntax

Hi,

It looks like you have one too many asterisks in your time specification. There are five fields: minute, hour, monthday, month, and weekday.

JP
Sanjay_6
Honored Contributor

Re: crontab syntax

Hi,

Try

1 12 * * * * /user/test/testme > /tmp/log.`/usr/bin/date +%m%d%H%M` 2>&1

Hope this helps.

Regds
Cheryl Griffin
Honored Contributor

Re: crontab syntax

command > /tmp/log.`date +'%m%d%H%M'
"Downtime is a Crime."
Deepak Seth_1
Regular Advisor

Re: crontab syntax

no luck

4 14 * * * /users/dseth/testme > /tmp/dseth.`/usr/bin/date +%m%d%H%M` 2>&1

I can cut and paste the above on command prompt and its work fine

-rw-r--r-- 1 root sys 5 Nov 8 14:04 /tmp/dseth.11081404

Something with environment . Did any of you tried on your system ?

Patrick Wallek
Honored Contributor
Solution

Re: crontab syntax

You must escape the % signs within the crontab file.

Use this:

1 12 * * * /usr/test/testme > /tmp/dseth.$(/usr/bin/date +\%m\%d\%H\%M)
Deepak Seth_1
Regular Advisor

Re: crontab syntax

patrick reply made the difference . Its working now .