LinuxQuestions.org
Register a domain and help support LQ
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 10-06-2005, 11:06 PM   #1
csmwlee
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Rep: Reputation: 0
logging daily cron jobs in separate files


I've written some scripts and use the crontab to schedule their running while all output would be directed to a log file

e.g. 0 0 * * * (cd /home/scripts; ./theScript.sh >> /home/logs/theLog.log)

i found the log keep expanding, thus I want to create a daily log
0 0 * * * (cd /home/scripts; ./theScript.sh >> /home/logs/theLog.`date +%Y%m%d`.log)

but the whole job stop running

what should i do
 
Old 10-07-2005, 01:48 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
You could try
Quote:
0 0 * * * (cd /home/scripts; ./theScript.sh >> /home/logs/theLog.`/usr/bin/date +%Y%m%d`.log)
,
just in case cron doesn't have date in its PATH.



Cheers,
Tink
 
Old 10-07-2005, 08:41 PM   #3
csmwlee
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Original Poster
Rep: Reputation: 0
hmm...

no luck
still not working ...

is there any way i could find out the logging of crontab?
 
Old 10-08-2005, 07:30 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
why not just write a single script you can call, and derive the date inside that?if this is a big important script, then event factoring in a command parameter to state a log redirect or console output is pretty easy.
 
Old 10-09-2005, 08:42 PM   #5
csmwlee
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Original Poster
Rep: Reputation: 0
i think that's probably my last option

just want to find out why that's not working
 
Old 10-10-2005, 10:30 AM   #6
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
There is also a neatness (& accompanying clarity) advantage:
  • Why clutter your crontab w/ long/complicated commands?
  • Why risk your crontab with every edit in the debugging process?
  • Why not use a separate script, where you can annotate your commands w/ comments -- invaluable 6 mo. later.
 
  


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
cron.daily question ralvy Slackware 6 12-09-2004 10:55 PM
crontab vs cron.daily ? SheldonPlankton Linux - Newbie 1 07-16-2004 12:10 PM
Daily Cron jobs with a PHP file Gargomel7 Programming 7 09-13-2003 07:21 PM
cron.daily MrJoshua Linux - General 2 03-19-2003 12:09 PM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM


All times are GMT -5. The time now is 07:18 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration