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
rollingpolicy.h(3)						       log4c							rollingpolicy.h(3)

NAME
rollingpolicy.h - Log4c rolling policy interface. Defines the interface for managing and providing rolling policies. SYNOPSIS
#include <stdio.h> #include <log4c/defs.h> #include <log4c/layout.h> Data Structures struct log4c_rollingpolicy_type log4c rollingpolicy type. Defines the interface a specific policy must provide to the rollingfile appender. Defines #define ROLLINGPOLICY_ROLLOVER_ERR_CAN_LOG 0x05 Typedefs typedef struct __log4c_rollingpolicy log4c_rollingpolicy_t typedef struct log4c_rollingpolicy_type log4c_rollingpolicy_type_t log4c rollingpolicy type. Defines the interface a specific policy must provide to the rollingfile appender. Functions LOG4C_API log4c_rollingpolicy_t * log4c_rollingpolicy_get (const char *policy_name) LOG4C_API const log4c_rollingpolicy_type_t * log4c_rollingpolicy_type_set (const log4c_rollingpolicy_type_t *a_type) LOG4C_API void log4c_rollingpolicy_set_udata (log4c_rollingpolicy_t *policyp, void *udatap) LOG4C_API int log4c_rollingpolicy_init (log4c_rollingpolicy_t *policyp, rollingfile_udata_t *rfup) LOG4C_API int log4c_rollingpolicy_fini (log4c_rollingpolicy_t *a_this) LOG4C_API int log4c_rollingpolicy_is_triggering_event (log4c_rollingpolicy_t *policyp, const log4c_logging_event_t *evtp, long current_file_size) LOG4C_API const log4c_rollingpolicy_type_t * log4c_rollingpolicy_set_type (log4c_rollingpolicy_t *a_rollingpolicy, const log4c_rollingpolicy_type_t *a_type) LOG4C_API const log4c_rollingpolicy_type_t * log4c_rollingpolicy_type_get (const char *a_name) LOG4C_API void * log4c_rollingpolicy_get_udata (const log4c_rollingpolicy_t *policyp) LOG4C_API rollingfile_udata_t * log4c_rollingpolicy_get_rfudata (const log4c_rollingpolicy_t *policyp) Detailed Description Log4c rolling policy interface. Defines the interface for managing and providing rolling policies. A rolling policy is used to confogure a rollingfile appender to tell it when to trigger a rolover event. Define Documentation #define ROLLINGPOLICY_ROLLOVER_ERR_CAN_LOG 0x05 Effect a rollover according to policyp on the given file stream. Parameters: policyp pointer to the rolling policy fp filestream to rollover. Returns: zero if successful, non-zero otherwise. The policy can return an indication that something went wrong but that the rollingfile appender can stull go ahead and log by returning an error code <= ROLLINGPOLICY_ROLLOVER_ERR_CAN_LOG. Anything greater than means that the rolling file appender will not try to log it's message. Typedef Documentation typedef struct __log4c_rollingpolicy log4c_rollingpolicy_t log4c rollingpolicy type typedef struct log4c_rollingpolicy_type log4c_rollingpolicy_type_t log4c rollingpolicy type. Defines the interface a specific policy must provide to the rollingfile appender. Attributes description: o name rollingpolicy type name o init() init the rollingpolicy o is_triggering_event() o rollover() Function Documentation LOG4C_API int log4c_rollingpolicy_fini (log4c_rollingpolicy_t *a_this) Call the un initialization code of a rolling policy. This will call the fini routine of the particular rollingpolicy type to allow it to free up resources. If the call to fini in the rollingpolicy type fails then the rollingpolicy is not uninitialized. Try again later model... Parameters: policyp pointer to the rolling policy Returns: zero if successful, non-zero otherwise. LOG4C_API log4c_rollingpolicy_t* log4c_rollingpolicy_get (const char *policy_name) Get a new rolling policy Parameters: policy_name a name for the policy Returns: a new rolling policy, otherwise NULL. LOG4C_API rollingfile_udata_t* log4c_rollingpolicy_get_rfudata (const log4c_rollingpolicy_t *policyp) Get the rollingfile appender associated with this policy. Parameters: policyp pointer to the rolling policy Returns: pointer to the rolling file appender associated with this policy LOG4C_API void* log4c_rollingpolicy_get_udata (const log4c_rollingpolicy_t *policyp) Get the rolling policy configuration. Parameters: policyp pointer to the rolling policy Returns: pointer to the rolling policy configuration. LOG4C_API int log4c_rollingpolicy_init (log4c_rollingpolicy_t *policyp, rollingfile_udata_t *rfup) Call the initialization code of a rolling policy. Parameters: policyp pointer to the rolling policy app the rolling appender this policy is used with Returns: zero if successful, non-zero otherwise. LOG4C_API int log4c_rollingpolicy_is_triggering_event (log4c_rollingpolicy_t *policyp, const log4c_logging_event_t *evtp, longcurrent_file_size) Determine if a logging event should trigger a rollover according to the given policy. Parameters: policyp pointer to the rolling policy evtp the logging event pointer. current_file_size the size of the current file being logged to. Returns: non-zero if rollover required, zero otherwise. LOG4C_API const log4c_rollingpolicy_type_t* log4c_rollingpolicy_set_type (log4c_rollingpolicy_t *a_rollingpolicy, const log4c_rollingpolicy_type_t *a_type) sets the rolling policy type Parameters: a_rollingpolicy the log4c_rollingpolicy_t object a_type the new rollingpolicy type Returns: the previous appender type LOG4C_API void log4c_rollingpolicy_set_udata (log4c_rollingpolicy_t *policyp, void *udatap) Configure a rolling policy with a specific policy. Parameters: policyp pointer to the rolling policy udatap a specific policy type, for example sizewin. Returns: zero if successful, non-zero otherwise. LOG4C_API const log4c_rollingpolicy_type_t* log4c_rollingpolicy_type_get (const char *a_name) Get a pointer to an existing rollingpolicy type. Parameters: a_name the name of the rollingpolicy type to return. Returns: a pointer to an existing rollingpolicy type, or NULL if no rollingpolicy type with the specified name exists. LOG4C_API const log4c_rollingpolicy_type_t* log4c_rollingpolicy_type_set (const log4c_rollingpolicy_type_t *a_type) Use this function to register a rollingpolicy type with log4c. Once this is done you may refer to this type by name both programmatically and in the log4c configuration file. Parameters: a_type a pointer to the new rollingpolicy type to register. Returns: a pointer to the previous rollingpolicy type of same name. Example code fragment: const log4c_rollingpolicy_type_t log4c_rollingpolicy_type_sizewin = { 'sizewin', sizewin_init, sizewin_is_triggering_event, sizewin_rollover }; log4c_rollingpolicy_type_set(&log4c_rollingpolicy_type_sizewin); Author Generated automatically by Doxygen for log4c from the source code. Version 1.2.1 Mon May 2 2011 rollingpolicy.h(3)