Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have some custom log files that are getting very big. (36 MB and 87 MB respectively). I have some other log files, that came with my distro, that are switched every week so they are the regular log file and a compressed backup. I think the squid log is one of those. example: cache.log, cache.log.1.gz to cache.log.5.gz
I believe this is done with a cron job. How do I make a cron job to compress and backup my custom log files every day?
My custom log files are:
/var/log/squidGuard/badurls.log
/var/log/squidGuard/squidGuard.log
Thanks for the reply. If you read the question, I need to know "HOW TO", not "what to".
In other words, I need a step by step guide to how to do what I am asking. What files I need to edit, what I need to type in, etc. That's why this question is in the newbie category, because I really don't know how to do it and never did it before.
I'm using Mandrake Multi Network Firewall with no GUI.
You might check out the man pages for logrotate. I'm not sure on your distro, but on fedora core there is a directory /etc/logrotate.d/ that contains all of the config files. For example the squid file looks like this:
Code:
[root@dbox logrotate.d]# cat squid
/var/log/squid/access.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/var/log/squid/cache.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/var/log/squid/store.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
# This script asks squid to rotate its logs on its own.
# Restarting squid is a long process and it is not worth
# doing it just to rotate logs
postrotate
/usr/sbin/squid -k rotate
endscript
}
Most of the details for the config files can be found in the man pages for "logrotate". If you use /etc/logrotate.d/squid it should already be included in a cron job. However as I said before this is dependant on your distro. But it sounded like you have log rotation going on and all you need to do is add these files to the process.
I just copied the same things that the squid logs have, since I basically want them to do the same thing. I did this last night and this morning the logs did not get backed up. Can you tell me what I did wrong?
I didn't really understand that last post. I have the file /usr/sbin/logrotate, but when I opened it in vi it was a bunch of gibberish. I guess this means it's a binary file, anyway I can't read it.
I looked in /etc/logrotate.conf and it has the line you mentioned.
I looked in /etc/crontab but it did not have my squid stuff in there. I do not know how my squid logs are getting logrotated. But I want my squidguard stuff to do the same thing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.