LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-21-2008, 12:35 PM   #1
dizowned
LQ Newbie
 
Registered: Jan 2008
Posts: 19

Rep: Reputation: 0
cron and the "+"


Basically I have a cron job that creates a file and I want to append the date to the file with specific formatting. I'm trying to use the data command to do this and whenever cron executes and comes across the "+" for the Format string part of the date command it just stops reading and that becomes the command - so ie the cron log has in it the command being executed as (..... cmd ouput_'date +) when it should be
(..... cmd output 'date +%F%m...'). Is there something weird with cron and the "+"?
 
Old 08-21-2008, 12:38 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
No. There is an issue with the % sign. It has a special meaning in crontab. Here is an excerpt from man 5 crontab:
Quote:
Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
You have to escape the % sign and the trick is done.
 
Old 08-21-2008, 12:49 PM   #3
dizowned
LQ Newbie
 
Registered: Jan 2008
Posts: 19

Original Poster
Rep: Reputation: 0
nvm, just figured out you have to escape the %.

edit...
Doh, beat me too it - thanks for the quick reply though.
 
  


Reply


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
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 09:31 AM
simple "echo > qbc" cron jobs doesn't run shole Linux - Newbie 3 09-23-2006 03:09 PM
"permission denied" error when cron job executes jillu Linux - Newbie 11 11-02-2004 02:19 PM
Monthly Archiving Script... help with "date" & "cron" Supp0rtLinux Linux - Software 3 01-03-2003 10:29 PM


All times are GMT -5. The time now is 06:42 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration