The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
log rolling chaandana Shell Programming and Scripting 0 06-19-2008 02:19 AM
Rolling back time Cameron UNIX for Dummies Questions & Answers 5 03-26-2002 09:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-18-2008
waaraa1331 waaraa1331 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
Log Rolling

I am using crontab to run a check on a program and make sure all is well...

I am making a vi file and then loading it as the crontab file using
shell> crontab < file_name

I am then trying to write a log file whose name dispays the current date in the format yr-m-d. I know the command "shell> date +%F" displays this format so in the vi when I was trying to write the file to a log i wrote this...
shell> ... > path/`/usr/bin/date +%F`-crontab.log
and since that didn't work i tried
shell> ... > path/`/usr/bin/date "+%F"`-crontab.logand so far it has not worked...in fact I don't even know where this file is being saved to as the directory has no new file...when I used just the 'date' command it worked but I need the format with "%F"...if it matters I am using solaris10 as my env. Any help would be greatly appreciated..thanks
  #2 (permalink)  
Old 08-18-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,569
Dont understand a thing...
What are you trying to do?

If its just log the activity of a program launched by cron, why not simply in crontab
* * * * * <your Program> 2&1 >>/var/adm/<your program>.log (or elsewhere...)
  #3 (permalink)  
Old 08-18-2008
waaraa1331 waaraa1331 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
my problem isn't getting cron to work its simply getting the log file to display the date format properly...the cron file works fine as far as functionality goes but I want the log file name to change based on the date...that is the only thing not working
  #4 (permalink)  
Old 08-18-2008
buffoonix buffoonix is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 145
I'm not quite sure what you meant.
Why would you want to write a log file manually? Usually some long running background process (e.g. daemon) would write to a log.
But if you need to edit it this should work
Code:
# vi  /var/log/whatever-$(date +%F).log
I'm not sure about the date formats on your Solaris box.
You may have to try it with this format instead
Code:
# vi /var/log/whatever-`date +%Y-%m-%d`.log
  #5 (permalink)  
Old 08-18-2008
waaraa1331 waaraa1331 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
Here is the exact line in the cron jobs file that I am having trouble with...the problematic parts are in bold...

0,10,20,30,40,50 * * * * /export/home/blah/blah.sh >> /export/home/blah/`date +%Y-%m-%d`-crontab.log

(blah.sh is a script that has been tested and works perfectly fine. The location of the 'date'-crontab.log file is in a user owned directory but I am the root user so permission should not be an issue)

I need to have a log file whose name is yr-m-d-crontab.log so that each day a new file is created with the logs for that day. This line, assuming it works, should do this since the day will change and a new file created once midnight rolls around.

I tried all the suggestions given to me so far in this post and nothing has worked...in fact it tends to not save a log file at all and I have no idea why
  #6 (permalink)  
Old 08-18-2008
buffoonix buffoonix is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 145
Gathering from the user's $HOME (viz. /export/home/user) I take this is happening on a Solaris box?
Often, for some odd reason, user accounts on Solaris get assigned the infamous csh as login shell.
What does a # useradd -D display?
The csh has severe redirection deficiencies.
In case this is a csh related issue, there is this article by Tom Christiansen,
that despite being more than ten years old, doesn't seem to have lost much of its relevance.
Csh Programming Considered Harmful
Though it shows many workarounds you should rather consider changing to a Bourne or Korn shell for cronjobs.
  #7 (permalink)  
Old 08-18-2008
waaraa1331 waaraa1331 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 5
'# useradd -D' displays...

UX: useradd: ERROR: Unexpected failure. Defaults unchanged.
group=other,1 project=default,3 basedir=/home
skel=/etc/skel shell=/bin/sh inactive=0
expire= auths= profiles= roles= limitpriv=
defaultpriv= lock_after_retries=
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:38 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0