I'm new to Linux but I'm about to start using a VPS to host my website. I've been reading about and it's been mentioned that I need to make sure that all of my logs are rotating and compressed, but I don't understand how to do that. I'll be using Plesk but I understand that it will only cover a few logs, so how do I make sure that all my logs are rotated? And is there an easier way to view them than by using grep/cat?
To flesh out what EightBitTony points out about
This is of interest since directives can supersede (contradict and override) one another, and they are processed inline; from the beginning of that section: "each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones)" so if you include a file then contradict a directive in it, this last directive wins. Get used to reading man pages! They are your friend!
If you look at your
There are logrotate tutorials around if you find the man page a little dense initially. It's a great tool. The easiest thing to do is set up an experimental conf file outside the default directory that you can run by specifying that on the command-line. Make it refer to something specific so you don't create a mess whilst experimenting, and you should be able to get a handle on how things work that way.
Note that you don't have to run logrotate via cron; you can do it manually or via some other method depending on how you prefer to administer the server.
Many Linux distributions include log rotation by default, for the common log file formats. I don't know CentOS well enough to say whether it's included, but the configuration is usually in
So if you're talking about the basic log files, they're probably already catered for. Logrotate usually leaves the rotated (and optionally compressed) logs in the original directory in which they were created (which of course, varies per log), with most operating system logs being found in /var/log (on many distributions).
Linux distributions with package managers and people packaging software, usually ensure that when you install something that has logs, a new entry gets placed in the relevant logrotate location. That's one of the things you 'get' with a Linux distribution that you don't get by just downloading and compiling source. It's not a guarantee, some packaged software doesn't have it, but it's more common than not.
If you want to report on logs (you won't want to read them all), then you need to look at solutions such as
It's okay for one or two servers, but it's too much to handle if you get up to half a dozen or more at which point you need something else.