Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
need help to rotate a log file manually
Results 1 to 6 of 6

Thread: need help to rotate a log file manually

  1. #1

    need help to rotate a log file manually

    plse tell me the steps about how to rotate the log file(logrotate)

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    Usualy what logrotate does, is renaming a certain logfile ie: messages to messages.1, then it compresses it and renames any previous messages.1.gz to messages.2.gz and so on, to make sure theres atleast the last 4 previous messages files residing.

    Ususaly it is easier to add the files you want to have logrotate look out for, than it is to manualy do it.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  3. #3
    dear redhead(mod),thnks for replying but can u tell me the exact steps about how to create manually do it???? i hav tried doin it but getting confused!!!

  4. #4
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    The manual steps are controled by a small script like
    Code:
    #!/bin/sh
    FILENAME="/your/location/your-file"
    
    
    if [ -f "$FILENAME".4.gz ]; then
        rm -f "$FILENAME".4.gz
    fi
    if [ -f "$FILENAME".3.gz ]; then
        mv -f "$FILENAME".3.gz "$FILENAME".4.gz
    fi
    
    if [ -f "$FILENAME".2.gz ]; then
        mv -f "$FILENAME".2.gz "$FILENAME".3.gz
    fi
    
    if [ -f "$FILENAME".1.gz ]; then
        mv -f "$FILENAME".1.gz "$FILENAME".2.gz
    fi
    if [ -f "$FILENAME" ]; then
        gzip -c "$FILENAME" > "$FILENAME".1.gz
        echo -n "" > "$FILENAME"
    fi
    But for a more simple way as I said, let logrotate handle it, create a file in /etc/logrotate.d with a section like:
    Code:
    /your/location/your-file {
       rotate 4  # create upto .4.gz
       compress  # gzip compresses the file
       missingok  # its OK if it's not there
       monthly    # could be weekly or daily
       notifempty # if file is empty dont rotate it
    }
    You can look at logrotate(8) for more info on which settings to give it.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  5. #5
    thnks redhead .....bbye

  6. #6
    Quote Originally Posted by abhijeet View Post
    plse tell me the steps about how to rotate the log file(logrotate)
    Hi. I am also in trouble with mine about rotating the log file. I hope that we can find some good ideas here.

Similar Threads

  1. Can I change it manually
    By haariseshu in forum Redhat / Fedora
    Replies: 1
    Last Post: 01-10-2008, 01:32 AM
  2. Squid Log Rotate
    By zmunawar in forum Redhat / Fedora
    Replies: 0
    Last Post: 02-08-2007, 05:42 AM
  3. Slackware 10.2, Update Initrd manually??
    By vwgtiturbo in forum Linux - Hardware, Networking & Security
    Replies: 5
    Last Post: 04-20-2006, 01:39 AM
  4. manually mount NFS file system.
    By smith786 in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 09-24-2005, 03:06 PM
  5. Changing screen resolution manually
    By Black666 in forum Linux - Software, Applications & Programming
    Replies: 6
    Last Post: 05-11-2002, 07:36 PM

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
  •