Cleaning the content of log files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cleaning the content of log files
# 1  
Old 11-14-2006
Cleaning the content of log files

Hi,

I am facing problems while trying to clean a log file(Means making its file Size zero).
I am not the owner of this file. From the command line, I can clean it by becoming a Sudo. (">logfilename").

I want to automate it using perl. But inside a script, sudo somehow doesnt seem to work.

Since I have to do this operation several times in the programs, its inconvenient to the the "Sudo" package provided by Perl as I need to set all the values of the Sudo structure everytime with different parameters.

The Sudo package is like this:

use Sudo;
my $su;

$su = Sudo->new(
{
sudo => '/usr/bin/sudo',
sudo_args => '...',
username => $name,
password => $pass,
program => '/path/to/binary',
program_args => '...'
}
);

$result = $su->sudo_run();

So, setting the atrributes of Sudo object everytime is inconvenient.

Is there any work around for it? I am using a BSD box and using bash as my shell.

Thanks,
Jyoti
# 2  
Old 11-15-2006
why not setup the script first and then have that installed in sudo with all the appropriate controls? then you only need to run one script ...


just a thought ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Comparing two files and list the difference with common first line content of both files

I have two file as given below which shows the ACL permissions of each file. I need to compare the source file with target file and list down the difference as specified below in required output. Can someone help me on this ? Source File ************* # file: /local/test_1 # owner: own #... (4 Replies)
Discussion started by: sarathy_a35
4 Replies

2. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

3. Shell Programming and Scripting

cleaning up files using find...

I am trying to cleanup a directory with around 4000 files, and using the below command to delete all .gz files older than 60 days, I am having the same issue of arguments being too long. is there a way i can use the same command to do what I intend to do. find /opt/et/logs/Archive/*.log.*.gz... (4 Replies)
Discussion started by: Shellslave
4 Replies

4. Shell Programming and Scripting

search for content in files. Name of files is in another file. Format as report.

Hi I have multiple files in a folder and one file which contains a list of files (one on each line). I was to search for a string only within these files and not the whole folder. I need the output to be in the form File1<tab>string instance 2<tab> string instance 2<tab>string instance 3... (6 Replies)
Discussion started by: pkabali
6 Replies

5. Shell Programming and Scripting

Files appear to have no content

I have about 11000 files on a hard disk that were generated by copying a directory structure from a dvd. The files are supposed to contain ascii data. I am unable to read or inspect the contents of several of the files, I receive the error no such file or directory. I am using cygwin on... (4 Replies)
Discussion started by: jvorwald
4 Replies

6. UNIX for Dummies Questions & Answers

Cleaning core files

Hello *! Just a short question. Where on the system i can find core files. I have one SUN server (Solaris 8) and from time to time I must clean core files on it. But i am not sure where i can find those files. Thank you in advance. :) (5 Replies)
Discussion started by: ghost01
5 Replies

7. UNIX for Dummies Questions & Answers

searching for content of files

Hi, This question may be quite newbish. I've stored a few files on my Unix system and am wondering how to search for their contents (i.e. I input the keyword and get a list of files with this keyword) I'd then like to put it on my website (php). I thought of find and grep, but am not... (19 Replies)
Discussion started by: Aretai
19 Replies

8. Shell Programming and Scripting

content need changes- many files

Hi, all Need some advise on this script i have some files in a directory, and i need to change the word XX in each files to YY, how can i perform a bulk changes/ thanks in advance for yr sharing (3 Replies)
Discussion started by: swchee
3 Replies

9. UNIX for Dummies Questions & Answers

cleaning log files

Say I have a log file called is there a way to clean out certain files in this log by or when I go to VI this file it tells me and I am guessing this means the file has become to large to append with VI so I was wondering if there was command with some argument to clean this out? Thanks ... (6 Replies)
Discussion started by: rocker40
6 Replies

10. UNIX for Dummies Questions & Answers

Cleaning text files

I wish to clean a text file of the following characters 1/2, 1/4, o (degrees) I cant display these characters. I have tried ALT+189 etc (my terminal emulator is set to ASCII). How do I display the above ? I am using HP UX 10. (5 Replies)
Discussion started by: ferretman
5 Replies
Login or Register to Ask a Question