Perl-log rotator


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl-log rotator
# 1  
Old 04-21-2010
Perl-log rotator

Sorry about that guys....I reread my post and understood why no one was answering-lol. Sorry.

Im trying to create a Perl script that checks for and creates files. (Im using messages, as you will see below).

Im trying to get the script to copy (if theres anything to copy) from messages to messages1. Then messages.1 to messages2. This is so daily messages will be moved and deleted.

This below is the code I have so far. Any help would be appreciated!!

Code:
#!/usr/local/bin/perl $username = "rgoforth" 
$filename = "/home/".$username."/messages"; 
$mess = "/home/".$username."/messages"/messages"; 
$mess1 = "/home/".$username."/messages"/messages.1"; 
$mess2 = "/home/".$username."/messages"/messages.2"; 
$mess3 = "/home/".$username."/messages"/messages.3"; 
$mess4 = "/home/".$username."/messages"/messages.4"; 

if (-e $filename){ 
open (FILE, ">$mess") or die $!; 
print[/URL] (FILE $mess1); 
close (FILE); 
}else{ 
print "Error: $filename doesn't exist\n";

Thanks!

Last edited by pludi; 04-21-2010 at 04:11 AM.. Reason: code tags have to be closed, too
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Log rotator

Hello guys. i have couple of log files which i need to rotate them . so i need a script to run every 30 minutes in the server and rotate the log files if they size pass the 100MB. would you please help me? (4 Replies)
Discussion started by: Ymir
4 Replies

2. Shell Programming and Scripting

*log to *.csv in perl

I want to convert the log files to xls. by bash script I converted it to csv, but I need to make some changes in some of them. please dont ask why xls and not csv. I need xls and this is to be a automated process. I am new to linux, bash and NULL in Perl. That would be nice if someone help me to... (6 Replies)
Discussion started by: frhling
6 Replies

3. Shell Programming and Scripting

Perl's buffered I/O is causing me to miss latest log file entries in log colorizer. How to fix?

I've been finding myself using a log file colorizer written in perl to reformat and colorize the output from many different programs. Mainly, however, I use it to make the output from "tail -f" commands more readable. The base perl script I use is based on "colorlogs.pl" available from the... (1 Reply)
Discussion started by: rcsteiner
1 Replies

4. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

5. Shell Programming and Scripting

Log maintain in Perl

hi , While working on perl, have to write a continuous log file which I can monitor. I tried like, open (LOG,'>'.$log.'/Report_'.$todaysdate.'.log') or die("Unable to create the log file"); print LOG "\nDate : ".`date`; But when I ran the script in backend and monitor log, it... (1 Reply)
Discussion started by: Deei
1 Replies

6. Shell Programming and Scripting

Copy input to log file in perl

Can anyone please correct the code. I am trying to copy the user input to an output file log.txt: the script works fine but when I am trying to copy the user input error is generated. Thanks in advance. #!/usr/bin/perl $temp = "/home/log.txt"; $reply = ""; print 'Enter the code:... (1 Reply)
Discussion started by: sureshcisco
1 Replies

7. Shell Programming and Scripting

Perl log parsing help

Hello, I'm sure this is a very simple problem, but I'm having trouble thinking of an efficient way to do the following: given a large centralized ssh-log, one file on a syslog server, not separated by machines (I wish it were), that looks something like this: Sep 27 16:20:56 machine-name... (1 Reply)
Discussion started by: droog72
1 Replies

8. Shell Programming and Scripting

perl parse log

Hi anyone can help.how can i get all second column data in this log below?? x 799002577959.pdf, 25728 bytes, 51 tape blocks x 800002357216.pdf, 25728 bytes, 51 tape blocks x aadb090910.txt, 80424 bytes, 158 tape blocks x tsese090909.txt, 13974 bytes, 28 tape blocks (4 Replies)
Discussion started by: netxus
4 Replies

9. Shell Programming and Scripting

Tailing 2 or more log files simultaneously PERL

Hi, I am having issue where I have to tail 3 log files continuously (forever) and while I am reading the files , parse them and shove the data into DB. I can do this with one file totally fine but how can I read 3 files at the same time? I am not really looking for code (but would be nice) but... (3 Replies)
Discussion started by: Dabheeruz
3 Replies

10. Shell Programming and Scripting

Log Monitoring through Perl

Hi, I am new to perl. I want to write a perl script to monitor logs. Where i want to monitor exceptions logged or any kind of error strings. I have a dir(On Solaris) with multiple log file which keeps rolling to .gz file after some time in that same dir. These logs files size keeps on... (0 Replies)
Discussion started by: solitare123
0 Replies
Login or Register to Ask a Question