Sponsored Content
Full Discussion: log rotation
Top Forums Shell Programming and Scripting log rotation Post 302232670 by dennis.jacob on Friday 5th of September 2008 02:07:39 AM
Old 09-05-2008
Quote:
Originally Posted by mirusnet
Hello all.

Due to some reason I can not use HUP to rotate needed log files.
So I use the standard method:
cp $file $file.1
cat /dev/null > $file

But if Java application in this time writing the output to $file,
in the beginning of it appears many "^@^@^@^@^@^@".

How to avoid it? Or how to remove these symbols, maybe sed?
Or maybe someone knows how to clean $file in the better way.

Thanks.

Code:
perl -i -ne 's/\^@//g; print;' filename

 

10 More Discussions You Might Find Interesting

1. HP-UX

Log rotation on HP-UX

Can anyone post a sample log rotate and archive configuration on HP-UX? I really don't know how to do that... :( (3 Replies)
Discussion started by: untamed
3 Replies

2. Shell Programming and Scripting

Log rotation script

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

log rotation and autosys

Hi, I current have many apps servers running and need to create a script to rotate logs daily, and then create an autosys job to delete logs that are older than 30 days. I was thrown into this and have no idea what to do, please help me get started, thanks! -----Post Update----- and i will... (6 Replies)
Discussion started by: new2learn09
6 Replies

4. Solaris

Log Rotation of Catalina.out

Hi, Recently i received a request to rotate logs of catalina.out (tomcat). The file size was about 807 MB. I used logadm to truncate the log ( -c ) and zip (-z 0) it. Everything worked fine, catalina.out.0.gz was created (22 MB) and the size of original catalina.out became 0kb. After... (2 Replies)
Discussion started by: Mack1982
2 Replies

5. Solaris

Solaris log rotation

HI, What is log rotation in Solaris ? What are the essential steps to perform log rotation in Solaris? (1 Reply)
Discussion started by: Revathi@1
1 Replies

6. Solaris

Log rotation, twice

hi folk, need advise regarding the log rotation, i have the logadm set at 30 2 * * * /usr/sbin/logadm so it supposed to rotate once per day, but now it rotated twice! but someone my log will rotate at 2:30 AM, but then another 2 hours later, it creates a new and rotate a new log again,... (2 Replies)
Discussion started by: dehetoxic
2 Replies

7. UNIX for Dummies Questions & Answers

Log Rotation

Hi Guys, Good morning, I just want to know and collect ideas on this one. Regarding rotation of logs as I've observed it's not consistently functioning. I have a server with 8 Partitions, each partition has a dedicated directory for the logs that is needed and I set it every 5mins (300secs) the... (1 Reply)
Discussion started by: rymnd_12345
1 Replies

8. Solaris

Log rotation

Hi All! I seem to have a problem with log rotation, unless I am doing something wrong, I have type the following command for testing purposes to see if the -s option works but he did not: logadm -w /var/adm/messages -C 8 -c -s 512k -t '/var/adm/messages.$n' -z 1 the file is now at this... (7 Replies)
Discussion started by: fretagi
7 Replies

9. OS X (Apple)

Mavericks log rotation

In Mavericks, Apple has apparently moved control of log rotation to ASL. There's a 'ttl' value to determine how long log files will stick around for. I can compress them, change the way they're named, limit them by size, etc. But the one thing I cannot find is how to NOT keep one log file per... (0 Replies)
Discussion started by: jnojr
0 Replies

10. AIX

Log rotation in PowerHA7

Hi All, I have a situation here ... HACMP is configured with application monitoring script, which is generating messages .... which is running every minute ... And every minute when monitoring script run, one one log file is generating .... and this log file is rotating ... which is rotating... (1 Reply)
Discussion started by: linux.amrit
1 Replies
namespace::clean(3)					User Contributed Perl Documentation				       namespace::clean(3)

NAME
namespace::clean - Keep imports and functions out of your namespace SYNOPSIS
package Foo; use warnings; use strict; use Carp qw(croak); # 'croak' will be removed sub bar { 23 } # 'bar' will be removed # remove all previously defined functions use namespace::clean; sub baz { bar() } # 'baz' still defined, 'bar' still bound # begin to collection function names from here again no namespace::clean; sub quux { baz() } # 'quux' will be removed # remove all functions defined after the 'no' unimport use namespace::clean; # Will print: 'No', 'No', 'Yes' and 'No' print +(__PACKAGE__->can('croak') ? 'Yes' : 'No'), " "; print +(__PACKAGE__->can('bar') ? 'Yes' : 'No'), " "; print +(__PACKAGE__->can('baz') ? 'Yes' : 'No'), " "; print +(__PACKAGE__->can('quux') ? 'Yes' : 'No'), " "; 1; DESCRIPTION
Keeping packages clean When you define a function, or import one, into a Perl package, it will naturally also be available as a method. This does not per se cause problems, but it can complicate subclassing and, for example, plugin classes that are included via multiple inheritance by loading them as base classes. The "namespace::clean" pragma will remove all previously declared or imported symbols at the end of the current package's compile cycle. Functions called in the package itself will still be bound by their name, but they won't show up as methods on your class or instances. By unimporting via "no" you can tell "namespace::clean" to start collecting functions for the next "use namespace::clean;" specification. You can use the "-except" flag to tell "namespace::clean" that you don't want it to remove a certain function or method. A common use would be a module exporting an "import" method along with some functions: use ModuleExportingImport; use namespace::clean -except => [qw( import )]; If you just want to "-except" a single sub, you can pass it directly. For more than one value you have to use an array reference. Explicitly removing functions when your scope is compiled It is also possible to explicitly tell "namespace::clean" what packages to remove when the surrounding scope has finished compiling. Here is an example: package Foo; use strict; # blessed NOT available sub my_class { use Scalar::Util qw( blessed ); use namespace::clean qw( blessed ); # blessed available return blessed shift; } # blessed NOT available Moose When using "namespace::clean" together with Moose you want to keep the installed "meta" method. So your classes should look like: package Foo; use Moose; use namespace::clean -except => 'meta'; ... Same goes for Moose::Role. Cleaning other packages You can tell "namespace::clean" that you want to clean up another package instead of the one importing. To do this you have to pass in the "-cleanee" option like this: package My::MooseX::namespace::clean; use strict; use namespace::clean (); # no cleanup, just load sub import { namespace::clean->import( -cleanee => scalar(caller), -except => 'meta', ); } If you don't care about "namespace::clean"s discover-and-"-except" logic, and just want to remove subroutines, try "clean_subroutines". METHODS
clean_subroutines This exposes the actual subroutine-removal logic. namespace::clean->clean_subroutines($cleanee, qw( subA subB )); will remove "subA" and "subB" from $cleanee. Note that this will remove the subroutines immediately and not wait for scope end. If you want to have this effect at a specific time (e.g. "namespace::clean" acts on scope compile end) it is your responsibility to make sure it runs at that time. import Makes a snapshot of the current defined functions and installs a B::Hooks::EndOfScope hook in the current scope to invoke the cleanups. unimport This method will be called when you do a no namespace::clean; It will start a new section of code that defines functions to clean up. get_class_store This returns a reference to a hash in a passed package containing information about function names included and excluded from removal. get_functions Takes a class as argument and returns all currently defined functions in it as a hash reference with the function name as key and a typeglob reference to the symbol as value. IMPLEMENTATION DETAILS
This module works through the effect that a delete $SomePackage::{foo}; will remove the "foo" symbol from $SomePackage for run time lookups (e.g., method calls) but will leave the entry alive to be called by already resolved names in the package itself. "namespace::clean" will restore and therefor in effect keep all glob slots that aren't "CODE". A test file has been added to the perl core to ensure that this behaviour will be stable in future releases. Just for completeness sake, if you want to remove the symbol completely, use "undef" instead. SEE ALSO
B::Hooks::EndOfScope THANKS
Many thanks to Matt S Trout for the inspiration on the whole idea. AUTHORS
o Robert 'phaylon' Sedlacek <rs@474.at> o Florian Ragwitz <rafl@debian.org> o Jesse Luehrs <doy@tozt.net> o Peter Rabbitson <ribasushi@cpan.org> o Father Chrysostomos <sprout@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by "AUTHORS" This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2012-12-04 namespace::clean(3)
All times are GMT -4. The time now is 08:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy