I have been searching for days to find a way to set a max size for a log.txt file using a cron job exicuting a shell script. Is it possible for a script to remove older entries in a log file to maintain a limited file size? If so, how?
It would be nice if unix supported circular files. On old HP3000, I could build a file of desired size, specify cir attribute, and output to the file would be circular.
The following downsizes log.txt back to 800 lines after it hits 1200 lines, but you could use "wc -c" to control on number of characters instead. I use tail +nnn logic because tail -nnn will go back only so far.
My script above is to get rid of the older portion of large files while maintaining the newer portion. It could downsize when a file hits a certain number of characters instead of number of lines. Both the wc and tail commands support number of characters.
But if you just want to empty the large files, that's a lot easier. The easiest way to empty a file and leave it there is:
> myfile
and if running as root, ownership and file permissions will remain unchanged. Normally you can use the -exec parameter on a find command to do some command on each qualifying file, such as:
find . -name "test*" -exec rm {} \;
but I was not able to get the redirection command above to work in this context. But there are several ways to feed the filenames, such as piping into xargs. I would suggest the following, but test it first by replacing the "> $fn" with "echo $fn":
Hi,
I've compiled a 64-bit version of ClamAV 0.98.7 on my Solaris 10 SPARC server. I have a selection of files all containing the eicar signature but clamd is only picking up the signature in the files <2GB.
I have the following set in clamd.conf, to remove file size checking:
MaxScanSize 0... (4 Replies)
I have a system with the following settings:
min:0.10
Assigned: 2.0
Max: 6.0
Partition is uncapped weight is 128.
I would like to know if even if this is uncapped, is the max it can use 6?
The actual pool has 16.
I remember reading about this somewhere but I don't remember can anyone... (3 Replies)
Hello All,
I am working on an issue, where I need to check the max file size of a file. If the file size exceeds 2 GB, then I need to generate an error message. Since the file system does not allow a file to be created larger than 2 GB, I am planning to use named pipes & AWK file to acheive my... (6 Replies)
There is a file in my Unix Server whose size will be constant.
But every day when the sheduled jobs run in the server, that file gets updated but the size does not change.
Upon doing file filename
It is dispalyed as a binary file.
Can anyone please explain how that file is created.
How is... (3 Replies)
I'm trying to set the open files value to 4000 on a SLES 9 system.
Current values:ulimit -n
1024
I can set it using this:ulimit -n 4000
ulimit -n
4000
But this obviously sets it only for the shell session where I run the command to set it. I want to set this to 4000 for all time.
... (3 Replies)
Hi All,
We are running HP rp7400 box with hpux 11iv1.
Recently, we changed 3 kernel parameters
a) msgseg from 32560 to 32767
b) msgmnb from 65536 to 65535
c) msgssz from 128 to 256
Then we noticed that all application debug file size increase upto 2GB then it stops. So far we did not... (1 Reply)
Does anyone know a way to determine the maximum filesize on a file system on Solaris, HP-UX, AIX, Linux, and OSF1 using the command line?
TIA (2 Replies)
We have Sun OS 5.9 we are doing a backup process (ProC program) that uses the function...
fprintf(fp,"%s;%s;%s;%s;%s;%ld;%ld;%ld;%ld;%s;%s;%s;%d;%s;%s;%s;%ld;%s;%s;%s;%ld;%ld;%s;%ld;%s;%ld;%s;%s;%c%c",x_contrno, x_subno, x_b_subno,x_transdate,x_last_traffic_date,BillAmt_s, x_billamount_int,... (10 Replies)