1

I found over a gigabyte of files in var/log/bootchart. I don't want any but the most recent file to be saved. Can this be done?

1 Answers1

0

You could probably set a cron script to do that.

I assume (in this answer) the files are named bootchart.log.1 and so on.

Run crontab -e as the root user, select your editor and add into the end of the file:

@reboot /bin/sleep 60 && /bin/rm /var/log/bootchart/bootchart.log.*

Let's break it down

@reboot Tells cron to run on reboot.
/bin/sleep The command CRON runs. This is the x of the && statement.
60 The delay for sleep, in seconds.
&& Fancy Linux for "do y after x is done" as in x && y
/bin/rm The y of the && statement. It is the "delete" command of Linux.
/var/log/bootchart/bootchart.log.* The file to delete for rm. It says "delete all files beginning with bootchart.log. (note the dot at the end) in the folder /var/log/bootchart/

About the bootchart.log.*, a file named bootchart.log.1 or bootchart.log.bak orbootchart.log.old or bootchart.log.chicken will be deleted, but bootchart.log itself will not.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172