How to make a cron job
Hello
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 help. |
You could create a script and then drop it in cron daily, or manually edit the crontab and add the script.
|
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 Hope this helps, Fordeck |
hi fordeck,
Based on your reply I have edited /etc/logrotate.d/squid to add the following lines. Code:
Thanks. |
Backed up? Or rotated?
Cheers, Tink |
Whatever the other ones do. You know, make a copy and compress it so it becomes logfile.log.1.gz and then start a new logfile.
Anyway, it didn't work. :( |
You'll need a shell script (called logrotate) like this:
Code:
#!/bin/sh include /etc/logrotate.d and you'll need a cron entry in /etc/crontab like so: Code:
50 23 * * * root /path/to/logrotate |
OK ummmmmmm
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. |
help, my logs are still not getting rotated. Anyone?
|
Still having the problem?
|
All times are GMT -5. The time now is 03:36 PM. |