log rolling


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting log rolling
# 1  
Old 06-19-2008
log rolling

Hi,

I'm thinking of running a script via cron (every hour) to do the log rolling.
The file is "file.txt" and there going to be 10 files rolling (file.txt.n).
The file is being written constantly by an application.
The script will do the following:

1. cat file.txt > file.txt.0
2. cat /dev/null >file.txt
3. i=9
4. while [ $i -ge 0 ]; do
mv file.txt.$i file.txt.($i+1)
i=$i-1
done

What would be the possible issues w.r.t. file handling or loosing data ?

Thanks
Ch.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Log all the commands input by user at real time in /var/log/messages

Below is my script to log all the command input by any user to /var/log/messages. But I cant achieve the desired output that i want. PLease see below. function log2syslog { declare COMMAND COMMAND=$(fc -ln -0) logger -p local1.notice -t bash -i -- "$USER:$COMMAND" } trap... (12 Replies)
Discussion started by: invinzin21
12 Replies

2. UNIX for Dummies Questions & Answers

Middled Rolling average

Dear Help, The input file is below --- 13 2238422.00000 101083.00000 0.89024 0.00416 0.00467 14 2238318.00000 101090.00000 0.89100 0.00416 0.00467 15 2238209.00000 101100.00000 0.90964 0.00424 0.00466 16 2238104.00000 101104.00000 0.97568 0.00463 0.00475 17 2237991.00000 101113.00000... (8 Replies)
Discussion started by: Indra2011
8 Replies

3. Shell Programming and Scripting

Monitor log entries in log files with no Date format? - Efficient logcheck?

is there a way to efficiently monitor logfiles that do not have a date or time format? i have several logs on several different servers that need to be monitored. but i realized writing a script for this would be very complex and time consuming giving the variety of things i need to check for i.e.... (2 Replies)
Discussion started by: SkySmart
2 Replies

4. UNIX for Dummies Questions & Answers

Rolling back SQL transaction

Can some one help me related to .sql file issue. I have a .sqlfile and tried to read the file thru unix. In the .sqlfile I have error rows as well and when error comes I dont want to proceed further and need to roll back all the transactions. sample .sql file below insert into test... (2 Replies)
Discussion started by: sri_aue
2 Replies

5. Linux

Rolling Back an Update

I am writing a software product and hope that it will work on a variety of Linux distributions. At the moment, I am trying to create some kind of Linux version of patches/upgrades of installed software. Gathering information on available updates isn't hard, nor is installation of updates, but I... (27 Replies)
Discussion started by: Brandon9000
27 Replies

6. HP-UX

Script to monitor /var/opt/resmon/log/event.log file

AM in need of some plugin/script that can monitor HP-UX file "/var/opt/resmon/log/event.log" . Have written a scrip in sh shell that is working fine for syslog.log and mail.log as having standard format, have interrogated that to Nagios and is working as I required . But same script failed to... (3 Replies)
Discussion started by: Shirishlnx
3 Replies

7. Shell Programming and Scripting

How can view log messages between two time frame from /var/log/message or any type of log files

How can view log messages between two time frame from /var/log/message or any type of log files. when logfiles are very big and especially many messages with in few minutes, I would like to display log messages between 5 minute interval. Could you pls give me the command? (1 Reply)
Discussion started by: johnveslin
1 Replies

8. AIX

rolling back Technology Level

Hi, is it possible to roll back currently updated Technology level ? what are steps required? Regards, Manoj (2 Replies)
Discussion started by: manoj.solaris
2 Replies

9. UNIX for Dummies Questions & Answers

Rolling back time

Hi all, Have a small problem. Back in October the pervious sys-admin (of a client's company) made the necessary adjustments to the system clock for daylight savings (Sydney time - +11 GMT). As far as I can gather, they just amended the time - NO TIMEZONE !?! Is there an effective and safe... (5 Replies)
Discussion started by: Cameron
5 Replies
Login or Register to Ask a Question
appender_type_rollingfile.h(3)					       log4c					    appender_type_rollingfile.h(3)

NAME
appender_type_rollingfile.h - Log4c rolling file appender interface. SYNOPSIS
#include <log4c/defs.h> #include <log4c/appender.h> #include <log4c/rollingpolicy.h> Functions LOG4C_API rollingfile_udata_t * rollingfile_make_udata (void) LOG4C_API int rollingfile_udata_set_logdir (rollingfile_udata_t *rfudatap, char *logdir) LOG4C_API int rollingfile_udata_set_files_prefix (rollingfile_udata_t *rfudatap, char *prefix) LOG4C_API int rollingfile_udata_set_policy (rollingfile_udata_t *rfudatap, log4c_rollingpolicy_t *policyp) LOG4C_API const char * rollingfile_udata_get_logdir (rollingfile_udata_t *rfudatap) LOG4C_API const char * rollingfile_udata_get_files_prefix (rollingfile_udata_t *rfudatap) LOG4C_API long rollingfile_get_current_file_size (rollingfile_udata_t *rfudatap) Variables __LOG4C_BEGIN_DECLS LOG4C_API const log4c_appender_type_t log4c_appender_type_rollingfile Detailed Description Log4c rolling file appender interface. The rolling file appender implements a logging mechanism of a list of files up to a maximum number. The files are written by default to the current directory with logging names folowing the pattern log.1, log.2 etc. These parameters may be changed using the appropriate setter functions. If the appender fails to open logfiles for writing then the messages are logged to stderr--it will continue to try to open the zero-th file for writing at rollover events so if it succeeds at some point to open that file the messages will start to appear therein and will no longer be sent to stderr. Switching from logging from one file to the next is referred to as a 'rollover event'. The policy that determines when a rollover event should happen is called a 'rolling policy'. A mechanism is provided to allow different rolling policies to be defined. Log4c ships with (and defaults to) the classic size-window rollover policy: this triggers rollover when files reach a maximum size. The first file in the list is always the current file; when a rollover event occurs files are shifted up by one position in the list--if the number of files in the list has already reached the max then the oldest file is rotated out of the window. See the documentation in the rollingpolicy_type_sizewin.h file for more details on the size-win rollover policy. Function Documentation LOG4C_API long rollingfile_get_current_file_size (rollingfile_udata_t *rfudatap) Get the prefix string in this rolling file appender configuration. Parameters: rfudatap the rolling file appender configuration object. Returns: the current size of the file being logged to. LOG4C_API rollingfile_udata_t* rollingfile_make_udata (void) Get a new rolling file appender configuration object. Returns: a new rolling file appender configuration object, otherwise NULL. LOG4C_API const char* rollingfile_udata_get_files_prefix (rollingfile_udata_t *rfudatap) Get the prefix string in this rolling file appender configuration. Parameters: rfudatap the rolling file appender configuration object. Returns: the prefix. LOG4C_API const char* rollingfile_udata_get_logdir (rollingfile_udata_t *rfudatap) Get the logging directory in this rolling file appender configuration. Parameters: rfudatap the rolling file appender configuration object. Returns: the logging directory. LOG4C_API int rollingfile_udata_set_files_prefix (rollingfile_udata_t *rfudatap, char *prefix) Set the prefix string in this rolling file appender configuration. Parameters: rfudatap the rolling file appender configuration object. prefix the logging files prfix to use. Returns: zero if successful, non-zero otherwise. LOG4C_API int rollingfile_udata_set_logdir (rollingfile_udata_t *rfudatap, char *logdir) Set the logging directory in this rolling file appender configuration. Parameters: rfudatap the rolling file appender configuration object. logdir the logging directory to set. Returns: zero if successful, non-zero otherwise. LOG4C_API int rollingfile_udata_set_policy (rollingfile_udata_t *rfudatap, log4c_rollingpolicy_t *policyp) Set the rolling policy in this rolling file appender configuration. Parameters: rfudatap the rolling file appender configuration object. policyp the logging files prfix to use. Returns: zero if successful, non-zero otherwise. Variable Documentation __LOG4C_BEGIN_DECLS LOG4C_API const log4c_appender_type_t log4c_appender_type_rollingfile rollingfile appender type definition. This should be used as a parameter to the log4c_appender_set_type() routine to set the type of the appender. Author Generated automatically by Doxygen for log4c from the source code. Version 1.2.1 Mon May 2 2011 appender_type_rollingfile.h(3)