LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-25-2011, 05:46 PM   #1
v8625
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:
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
 
Old 02-25-2011, 06:31 PM   #2
macemoneta
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: 344Reputation: 344Reputation: 344Reputation: 344
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'

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:55 AM.

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