Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-25-2011, 05:46 PM   #1
LQ Newbie
Registered: Sep 2002
Posts: 11

Rep: Reputation: 0
need to echo / printf string containing date as parameter in cron

Is it possible to get cron to echo (or printf) the following string:
(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
Old 02-25-2011, 06:31 PM   #2
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 336Reputation: 336Reputation: 336Reputation: 336
How about just:

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

Last edited by macemoneta; 02-25-2011 at 06:33 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date comparison with 'string date having slashes and time zone' in Bash only TariqYousaf Programming 2 10-08-2009 07:37 AM
How to display (printf) selective parameter based on conditions eryn Programming 10 08-26-2009 01:09 PM
php, printf vs echo snowtigger Programming 3 04-17-2009 02:47 AM
C string and printf question exvor Programming 7 12-10-2005 10:53 AM
std string class and printf The_Nerd Programming 3 06-28-2004 10:46 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration