LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 09-09-2011, 10:16 AM   #1
frumpus
Member
 
Registered: Feb 2010
Posts: 38

Rep: Reputation: 0
crontab string character limit?


I was calling a nightly backup script with the following entry.

Code:
00 03 * * 0,2,3,4,5,6 /backup/nightly_backup.sh > /backup/logs/todays.log
This ran fine but I had to rename the logs every day. To simplify things I changed the crontab entry to this:

Code:
00 03 * * 0,2,3,4,5,6 /backup/nightly_backup.sh > /backup/logs/`date --date='1 day ago' +%d-%b-%Y`.log
Now I get the following error, which comes by mail rather than going in the log file, which does not get created at all.

Code:
/bin/sh: -c: line 0: unexpected EOF while looking for matching "'
/bin/sh: -c: line1: syntax error: unexpected end of file
So it seems like my crontab entry is getting truncated somewhere in the middle of '1 day ago'. I would be a lot more willing to accept this if I had gone over 256 chars or something but this line is barely over 100. Does crontab have such a char limit? Does crontab not support back quotes in this way? Am I blind and unable to see some obvious syntax error?

Any clues, or alternate log naming suggestions, would be appreciated.
 
Old 09-09-2011, 10:20 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
Hi,

The % is special in cron, you need to escape it.

Too my knowledge only the first one is special, but I'm not entirely sure about that.

Hope this helps.
 
1 members found this post helpful.
Old 09-09-2011, 10:22 AM   #3
frumpus
Member
 
Registered: Feb 2010
Posts: 38

Original Poster
Rep: Reputation: 0
I will give that a shot, thanks!
 
Old 09-09-2011, 10:24 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400Reputation: 2400
You're welcome
 
Old 09-09-2011, 01:11 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
While this won't speak directly to your question, I'd add that you might consider putting the redirection intelligence into nightly_backup.sh itself. Unless you call it from different places (and redirect it to different files), that would clean up your crontab and "solve" the problem you're seeing.
 
  


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
How to replace last character string nicklau81 Programming 10 01-21-2011 03:28 AM
get value in character string Abid Malik Programming 1 10-23-2010 02:15 AM
Handle $ character in a string MaryG Linux - Newbie 4 09-11-2009 06:13 AM
Test for last character in string cgraham1 Programming 14 06-11-2009 01:25 PM
Social groups 1000 character limit. H_TeXMeX_H LQ Suggestions & Feedback 2 03-06-2009 08:17 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 03:02 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