LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   need to echo / printf string containing date as parameter in cron (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-echo-printf-string-containing-date-as-parameter-in-cron-865061/)

v8625 02-25-2011 05:46 PM

need to echo / printf string containing date as parameter in cron
 
Is it possible to get cron to echo (or printf) the following string:
1110225^1110225^1110225^1110225^1110225
(with 110225 obviously being current date - at command line I obtained this string using
printf 1$(date +"%y%m%d")^1$(date +"%y%m%d")^1$(date +"%y%m%d")^1$(date +"%y%m%d")^1$(date +"%y%m%d")

But cron does not like this string - says
.... printf 1$(date +"
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/db2inst1>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=db2inst1>
X-Cron-Env: <USER=db2inst1>

/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file

macemoneta 02-25-2011 06:31 PM

How about just:

Code:

/bin/date +'1%y%m%d^1%y%m%d^1%y%m%d^1%y%m%d^1%y%m%d'


All times are GMT -5. The time now is 09:16 AM.