Results 1 to 8 of 8

Thread: adding squid logs to logrotate

  1. #1

    adding squid logs to logrotate

    What's the proper way to add my squid logs to /etc/logrotate.d/syslog? Here's the sample config:

    /var/log/messages {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    Will it be the same /bin/kill.. line to use for the squid logs? What does it do anyway (/bin/kill..)?

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re:adding squid logs to logrotate

    in short:
    # > man kill
    DESCRIPTION
    The command kill sends the specified signal to the specified process or process group. If no signal is spec*
    ified, the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For
    other processes, it may be necessary to use the KILL (9) signal, since this signal cannot be caught.
    # > man 7 signal
    DESCRIPTION
    Linux supports the signals listed below. Several signal numbers are architecture dependent. First the signals
    described in POSIX.1.


    Signal Value Action Comment
    -------------------------------------------------------------------------
    SIGHUP 1 A Hangup detected on controlling terminal
    or death of controlling process
    Generaly you use kill to send the HUP signal to your current running process (the cat /var/run/syslogd.pid 2> /dev/null will give the process ID of your running process, in this case syslogd.
    This is a logrotate, usualy any process with a pointer to a logfile, or any file for that matter, will continue writing to that location, even if the file has been deleted. Because in *nix world (or most filesystems) it is just the filesystems refference to the filelocation that gets deleted. So processes currently using a pointer to the file, will assume it still exists.
    The HUP signal will for most processes, halt them, and ask them to reattach filepointers (or reread the config file) Thus since your rotation of the logs removed the log-file, the process is required to generate a new one.

    So the long version:
    01: /var/log/messages {
    02: postrotate
    03: /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    04: endscript
    05: }
    Line 01: Any output produced by this next act, will be piped to /var/log/messages
    Line 02: This following is to be performed emidiate after the rotate of logfiles.
    Line 03: Send the HUP signal to process ID found in /var/run/syslogd.pid, if some error happened, return true to satisfy the continues running of the rotate script.
    Line 04: Well thats the end of what is to be run after rotation of log-files
    Line 05: What ever output produced befor this ending bracket, will be found in Line 01 mentioned file.

  3. #3

    Re:adding squid logs to logrotate

    You mean to say that any program logs PID are in /var/run/syslogd.pid? So if i want to rotate my squid logs this is how it will look like.

    /var/log/squid/cache.log {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    /var/log/squid/store.log {
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
    }

    Is this correct?
    Thanx a lot redhead...i really appreciate it

  4. #4
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re:adding squid logs to logrotate

    I can't remember where squid puts it's PID but if it does, then what you need to do is make a file called squid in /etc/logrotate.d/ which contains something like:
    Code:
     /var/log/squid/cache.log /var/log/squid/store.log {
        missingok
        sharedscripts
        weekly
        postrotate
            /usr/bin/killall -HUP squid || true
        endscript
    }
    What this does, is to take the /var/log/squid/cache.log and /var/log/squid/store.log and rotates them, the missingok stands for, should one of the logfiles be missing, it's not a big deal.. Sharedscripts, means that the kill line is only run once, else it will be run for every logfile mentioned. Weekly means, rotate every week (you could set this to daily if you like, but thats an awfull lot of rotates.) Since I don't know where squid puts it's PID I've decided to use the killall function, sending the HUP signal to any PID found for a process named squid (If this is what you chose, please ensure that squid will ba named squid, and not something like squid-run or /usr/sbin/squid) since in thos cases killall will claim theres no such running process. This can be done with a `ps aux |grep squid` which will as the last column show the actual name squid is using when running.

    # > man 8 logrotate
    will give you alot more info on how to use it, look under "CONFIGURATION FILE"

  5. #5
    Mentor
    Join Date
    Jun 2001
    Posts
    1,672

    Re:adding squid logs to logrotate

    Hey redhead,

    We've received some very positive feedback about you responses to this thread. Would you consider turning this into a PET?

  6. #6
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re:adding squid logs to logrotate

    If I have the time.. Sure, but as you can see from my activity the past few month, I havn't had that much spare time to join in on the forum.

    But I'll look into it in the following week.

    --Edit--
    Come to think of it, I wouldn't even know what section of the PET's it would fit into.. (Tools perhaps?? )

  7. #7

    Re:adding squid logs to logrotate

    [quote author=cloverm link=board=1;threadid=5342;start=0#52133 date=1034858317]
    Hey redhead,

    We've received some very positive feedback about you responses to this thread. Would you consider turning this into a PET?
    [/quote]

    Sorry for my ignorance. But what's a PET?

  8. #8
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re:adding squid logs to logrotate

    PET: Plain English Tutorials

    Kinda like hints, gochas, remember this when... etc.
    like the NHFs at LNO

Similar Threads

  1. Replies: 1
    Last Post: 06-27-2013, 11:57 PM
  2. Red Hat Logs
    By Rukasboy in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 07-08-2002, 10:10 PM
  3. logrotate and cron
    By Baldy in forum Linux - General Topics
    Replies: 4
    Last Post: 06-14-2002, 06:31 PM
  4. Apache Logs...
    By groundzero in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 04-22-2002, 04:47 PM
  5. apache logs
    By agar in forum Linux - Hardware, Networking & Security
    Replies: 10
    Last Post: 01-19-2002, 03:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •