Log files are good because they log stuff, so you can find out what’s been going on and troubleshoot. But they tend to accumulate and can actually fill up your hard drive. Most Linux distros have automatic log file management for common system logs, but if you are running something on your server that keeps a log not thusly covered, you may have to manage that log file by yourself.
You could have a cron entry that simply deletes the log files in question every week or so, but then you lose the benefits of having a log file to begin with. The usual solution to this is called “Log Rotation” and it works like this:
The usual solution to the space problem is to rotate your log files. (We’ll see an unusual solution later in this section.) After a specific duration has passed or a file size has been reached, the current log file is moved to another name, e.g., logfile.0. The logging process is then continued into an empty file. At the next interval or limit, we repeat the process, first moving the backup file (logfile.0 ) to another name (like logfile.1). This process is repeated until a set number backup files have been created. The oldest backup file at that point is deleted.