LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-19-2012, 01:46 AM   #1
abhitanshu
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Rep: Reputation: Disabled
One issue with Crontab


Hi,
I am trying to execute an script using cron and want to capture its logs.

34 07 * * * /tmp/Script.sh >/var/tmp/Log/`date +%d%m%Y%H%M%S`_Script.log

But i am getting error as -

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

I had tried below options as well but none had worked -

1. Keep timestamp value in a variable and using that and use that TIMESTAMP=`date +%d%m%Y%H%M%S`

2. use $() instead of ` `

3. use "` `"

4. use $({ })

However all these options work perfectly fine manually.

Thanks.
 
Old 09-19-2012, 02:22 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Seen from cron the % is a special character and needs to be escaped (`date "+\%d\%m\%Y\%H\%M\%S"`_Script.log)

http://www.ducea.com/2008/11/12/usin...ontab-entries/ (search for crontab escape special characters for more)

An even better solution would be to make the creation and filling of the log file part of the script.
 
Old 09-19-2012, 03:07 AM   #3
abhitanshu
LQ Newbie
 
Registered: Jul 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks,
It worked.
 
Old 09-24-2012, 02:34 PM   #4
tgs78
LQ Newbie
 
Registered: Aug 2012
Posts: 6

Rep: Reputation: 0
An article explaining the Linux cronjob scheduling with the help of examples.

<moderated>

Hope you will find this post useful !

Last edited by colucix; 10-20-2012 at 08:43 AM. Reason: Driving traffic to your own blog is not allowed at LQ!
 
  


Reply

Tags
cron, crondaily, linux +, shell script



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
[SOLVED] Crontab issue pinga123 Linux - General 2 03-17-2011 01:56 AM
crontab issue,need help aditya_moon Linux - Newbie 2 02-07-2011 10:54 PM
[SOLVED] Crontab Issue shii_va Linux - Server 2 09-15-2009 11:30 AM
crontab issue adnanm Linux - Newbie 1 03-16-2007 02:28 AM
crontab issue houssamfarag Red Hat 2 06-27-2006 11:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:59 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
Open Source Consulting | Domain Registration