![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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
|
|
||||
|
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 You may have to try it with this format instead Code:
# vi /var/log/whatever-`date +%Y-%m-%d`.log |
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
'# 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= |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|