08-24-2009
Logfile rotation script.
I'm trying to find or create a Perl script that:
Checks for and creates these files:
notes
notes.1
notes.2
notes.3
notes.4
The first represents the current log file and the others are older versions. Each time the script runs it would check for the existence of notes.3 and, if it exists, move it to notes.4. Then is should check for notes.2 and move it to notes.3 and so on, until notes is moved to notes.1.
I've looked on the net already, but they're just too complex and try to do too much compared to my requirements.
Does anyone know of a script that does this, or do you have any code that could be adapted easily?
Thanks!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello all
Does anyone has an intersting script or a good freeware tool for log rotation that is good for Unix and Linux as well ?
My thanks in advance (4 Replies)
Discussion started by: yelalouf
4 Replies
2. Shell Programming and Scripting
I have the below script to help with disk space cleanup that finds logs older than a specified number of days (say 10 days). I need it to grab "active" logs as well. Problem is an "active log" will not get archived unless I put in 0 days which I don't want to do, I need to leave the past 10 days,... (2 Replies)
Discussion started by: theninja
2 Replies
3. Shell Programming and Scripting
Hello guys.
I've recently written a basic utilities script just for home use.
and i want to attach a logfile to it that will record all the commands that where executed in that script. Then just so i can add the d%b%y% and make each logfile unique and i can look back in each logfile to see what i... (9 Replies)
Discussion started by: matt02
9 Replies
4. Shell Programming and Scripting
Hi,
I'm trying to write a logfile monitor script that reads the logfile and then emails out once there is an error with SQL in. Here is my attempt below which does not work. I'm not much of a scripter as you can probably see but some pointers in the right direction would be much appreciated.
... (3 Replies)
Discussion started by: elmesy
3 Replies
5. Shell Programming and Scripting
I have application which to the heavy stdout and I have diverted the stdout to log file.
this log file is writing very heavily and we have a script which rotates the logs.
logic for rotation is smthing like
cp logfile logfile.1
cat /dev/null > logfile
this logic was working fine till we... (3 Replies)
Discussion started by: navinmistry
3 Replies
6. Shell Programming and Scripting
Hi,
I would like to implements monitoring tool which looks at the logfile and sends me an email with error messages from the logfile.
The runtime errors are printed in logfile. The logfile also contains some warning and debugging messages.
For errors, the line will start with “Error”., the error... (1 Reply)
Discussion started by: LinuxLearner
1 Replies
7. Shell Programming and Scripting
Here's the problem.
I have a shell script running for every one minute as cronjob that outputs to a log file. I want to be able to take the data from the log file and insert it into a mysql database. The script needs to run at a set period of time and remove the log file data once the insert is... (7 Replies)
Discussion started by: kgrvamsi
7 Replies
8. Shell Programming and Scripting
Unix Gurus,
I have a shell script which has few "echo" statements. I am trying to create a logfile where all the outputs of the echo statement sare stored.
I will have to add this as the final step in the existing script so that everytime the script runs, a logfile is generated with all the... (1 Reply)
Discussion started by: shankar1dada
1 Replies
9. Shell Programming and Scripting
I have an application that rotate its log once it reaches 100mb and it keeps a total of 24 logs. I am trying to write a script to run daily to tar up the previous day logs files and move them to a different directory. here is a long listing of the logs in the directory:
-rw-r--r-- 1 user1 ... (6 Replies)
Discussion started by: e_mikey_2000
6 Replies
10. Shell Programming and Scripting
Bonjour,
I've wrote a script to monitor a logfile in realtime. It is working almost perfeclty except for two things.
The script use the following technique :
tail -fn0 $logfile | \
while read line ; do
... some stuff
done
First one, I'd like a way to end the monitoring script if a... (3 Replies)
Discussion started by: Warluck
3 Replies
LEARN ABOUT BSD
nfarchive
NFARCHIVE(8) System Manager's Manual NFARCHIVE(8)
NAME
nfarchive - archive notesfiles
SYNOPSIS
nfarchive [ -# ] [ -d ] [ -m- or -m+ ] [ -w# ] [ -f file ] topic [ ... ]
DESCRIPTION
Nfarchive is used to expire notes that have not been modified in a certain amount of time. Archives are stored in ``archive notesfiles''.
The -# parameter is the number of days a notestring must be idle (no new responses) before being eligible for archival.
Expired notestrings are either deleted or placed in an archive. The -d parameter tells nfarchive to delete expired notestrings. If unse-
lected, the expired notestrings are placed in an archive.
The -m+ option specifies that only notes marked with a director message are eligible for expiration. -m- specifies that only notes without
a director message are eligible for expiration. By default, the expiration algorithm is indifferent to a note's director message status.
The -w# option specified the working set size for the expired notesfiles. The specified number represents the minimum number of notes to
leave in the notesfile.
The expiration threshold, working set size, expiration action, and director message requirements can all be specified as a director's
option in each notesfile. Specific values override what is specified on the nfarchive command line. A default value specifies using the
value specified on the command line.
The -f parameter specifies a file containing a list of notesfiles to archive. Notesfiles can also be specified on the command line.
By default, the archive of notesfile /usr/spool/notes/somenotes is in /usr/spool/oldnotes/somenotes. The archive of
/some/other/place/somenotes also defaults to /usr/spool/oldnotes/somenotes. To prevent collisions of this nature, mapping between active
and archive notesfiles is implemented. The file /usr/spool/notes/.utilities/net.alias/Archive-into contains lines of the form:
active-notesfile:archive notesfile
Lines in this file beginning with `#' are comments. Notesfiles without an entry in this file are archived into the /usr/spool/oldnotes
directory with the appropriate last component.
When initially created, an archive notesfile has an access list matching its active counterpart. Currently, only directors are allowed to
write in an archive notesfile. Nfarchive refuses to archive an archive notesfile.
FILES
/usr/spool/notes/.utilities where this programs lives.
/usr/spool/notes/.utilities/net.alias/Archive-into
maps active notesfiles into their archives.
/usr/spool/notes Default notes data base
/usr/spool/oldnotes Default archive directory
SEE ALSO
notes(1),
The Notesfile Reference Manual
AUTHORS
Ray Essick (uiucdcs!essick, essick%uiuc@csnet-relay.arpa)
Department of Computer Science
University of Illinois at Urbana-Champaign
Urbana, IL
Rob Kolstad (kolstad@convex.UUCP)
CONVEX Computer Corporation
Richardson, TX
University of Illinois NFARCHIVE(8)