lucky13
Group: Members
Posts: 1478
Joined: Feb. 2007 |
|
Posted: Jan. 22 2008,00:25 |
|
I saw you were on after I replied but you didn't answer. If what I wrote is what you want to do, you can use a script like this to start the weekly log:
Code Sample | #!/bin/bash lognumber=$(date +%Y%W) exec touch filename.$lognumber |
Give it a name (logmaker), chmod +x, in $PATH (such as /opt/bin), add a weekly cron job with that. Run this week, it gives you a file named "filename.200803" and the next week would be the same but 04. That will give you sequential weekly logs if that's what you want. It's also an optional step -- the next one should create the file if it doesn't already exist, but my preference is to use touch even if it's an extra step.
EDIT: Cleaned up everything and am leaving just this part to reduce possible confusion. This would be the daily script to set in your crontab...
Code Sample | #!/bin/bash
# set variables lognumber=$(date +%Y%W) logday=$(date [whatever you want -- standard date, day of week, etc.])
# if you want a timestamp: echo $logday >> filename.$lognumber
# this line does what you seem to want: cat thefileyouwantlogged >> filename.$lognumber
# the next two entries are to clear and restart the daily log file: rm thefileyouwantlogged touch thefileyouwantlogged |
The last two entries are redundant if the file already resets itself daily anyway. You can also leave out the logday and echo $logday entries if you don't care about timestamping each entry. Set the logday to whatever variables you want (Google: linux man date). Use full paths for "thefileyouwantlogged" and "filename.$lognumber" so you won't have any drama.
I don't know what you meant by brute force. Or even if this is what you wanted. Many ways to skin a cat. Like I said, I would do a weekly job to touch the weekly log file.
-------------- "It felt kind of like having a pitbull terrier on my rear end." -- meo (copyright(c)2008, all rights reserved)
|