This is a discussion on Rotating nohup.out without killing the application within the Linux Administration forums, part of the Linux Forums category; I am looking for ideas on how to solve a problem with a nohup.out file that is growing faster ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am looking for ideas on how to solve a problem with a nohup.out file
that is growing faster than expected. While we change to a better logging mechanism we're using the stdout to dump a bunch of debugging messages (a bunch is actually a lot!!). Any hows, when the application runs for a few days the nohup.out file could be 1G in size and to search for something on that file becomes a pain in the neck. The way I am doing that is pretty much manually. Stop the app, move the file out and restart the app (using nohup). I don't know if any of you guys know a better way to either rotate the nohup.out (by date or size, don't care) or to redirect the stdout to a logging application. I have been looking around in the groups and on the net but can't find anything that will give me some lights on how to do it. Ciao, Igor |
|
|||
|
igorojas@yahoo.com (igor) wrote in message news:<28c50361.0407071516.70f6ed19@posting.google. com>...
> I am looking for ideas on how to solve a problem with a nohup.out file > that is growing faster than expected. If the log file is too large, you could use the 'split' utility to break it into pieces. For this example, I will create an empty "log" file using 'dd' that is 4GiB in size, then split it into 512MiB pieces: $ dd if=/dev/zero bs=1024x1024 count=4096 > /var/log/app.log $ split --bytes=512m /var/log/app.log /var/log/app. $ ls -1 --size --human-readable /var/log/app.* 512Mi /var/log/app.aa 512Mi /var/log/app.ab 512Mi /var/log/app.ac 512Mi /var/log/app.ad 512Mi /var/log/app.ae 512Mi /var/log/app.af 512Mi /var/log/app.ag 512Mi /var/log/app.ah 4.0Gi /var/log/app.log However, you probably want to do this while the log file is being generated rather than wait until it gets to be 4.0GiB in size. So, use a pipe: $ nohup dd if=/dev/zero bs=1024x1024 count=4096 | split \ --bytes=512m - /var/log/app. This time I used the '-' in place of the input file from above since I want 'split' to read from the pipe instead. This will create log files app.aa, app.ab, ... , each 512MiB in size -- choose a size that is convenient for you. You could then use 'find' to remove the old files automatically, to put in your login script or in a cron job: $ find /var/log/ -name "app.*" -atime +7 -and -mtime +7 \ -exec rm '{}' ';' That will delete all log files that have the prefix 'app.' that have not been accessed or modified in the last 7 days. So if a coworker is still searching one of the log files frequently, it won't be deleted when that command is run. |