Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to save and clear the logs in Windows, but I'd like to do the equivalent in Linux. I have a requirement to save those logs for a very long time. Could someone sort of spell out the command lines for each of those?

share|improve this question

You will find the logs under /var/log, there are several there. Most Linux distributions run a program called logrotate periodically, which moves, e.g., log.3 to log.4, down to log.1 to log.2, and finally log to log.1. Exact details are configurable. So you'd need to save all those files, perhaps by writing them monthly to a CD (again, period of rotation is configurable, so you'll have to adjust/reconfigure). Sorry, without more details it is hard to give more specific advise.

Your best bet is to get yourself a Linux geek to configure for, say, monthly backups in the configuration, and automatize the writing to CD/DVD.

share|improve this answer

While your question sounds reasonable coming from a Windows background, it's not quite as clear cut as you might be thinking. *nix logs are often found in files or subdirectories of /var/log though specific applications might write their logs anywhere.

Initially, logs are usually written as plain text files. Most common applications (apache, mysql, syslog, etc) also have logrotate rules; that is, a batch job that runs in preset intervals that takes the text file and zips it up in /var/log, numbers it appropriately, and stores it. You can have logrotate perform scripts to mail, scp, ftp transfer, copy to a network share, or any number of things the log it's working on. Common practices usually mean shipping the logs somewhere other than the host it's on, so the logs are preserved in the event of disk corruption, fire, or other catastrophe. There's information on how to configure logrotate here:


For more complicated or larger systems with many hosts, a log aggregation approach is better. This effectively ships the logs from the host to one or more central log storage servers, for safekeeping and ease of reading. Programs like logstash, graylog2, and splunk all offer varying degrees of features to this effect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.