Results 1 to 16 of 16
  1. #1
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    746

    Are these commands safe?

    My harddrive files up with logs fast

    cp /dev/null access_logs
    cp /dev/null error_logs

  2. #2
    Join Date
    Aug 2001
    Location
    United kingdom
    Posts
    1,003
    Yes. those commands should be fine, if you're looking to reset the error and access logs to zero. Have you setup log rotation on your logs? That will allow your logs to grow and then deleted after some time.

    Alan
    Alan Ho
    Former Systems Administrator

  3. #3
    There's more to it than just the copy. You must also restart apache immediately after having done the copies otherwise you will run into all sorts of problems with lost log file information when you do eventually restart and the space won't actually be freed up on the file system.

    As suggested, look into logrotate (man logrotate) and make sure it is running daily and configured correctly.

  4. #4
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    746
    What are some must know commands for freebsd? What are the top 20 commands that you use the most to solve problems?

  5. #5
    You're probably best either buying a beginners guide to *BSD/*NIX, or looking for one on the web, that explains from the beginning how to approach the subject from being a user to a systems administrator. It takes a rich combination of learning, experimenting and experience and is probably best done through the guidance of a publication, at least initially.

    If you must, I'd make sure that you're familiar with and understand (in no particular order) the following generic utilities:
    cd
    pwd
    pico
    vi
    tar
    pwd
    ps
    top
    netstat
    df
    cp
    mv
    rm
    rpm (for various Linux platforms)
    less
    last
    grep
    find
    cat
    tail

    (I counted them too, there're 20 ); )

  6. #6
    Could you explain how is it going to work?
    Open httpd.conf and comment/delete the line that says where to write logs and you're finished.
    How can you copy device? /dev/null is device, not a file, explain please.
    Powered by AMD & FreeBSD.
    "Documentation is like sex:
    when it is good, it is very, very good;
    and when it is bad, it is better than nothing."

  7. #7
    Join Date
    Jan 2002
    Location
    Atlanta, GA
    Posts
    1,249
    /dev/null. AKA the bit bucket, that to which all data must go, or the great terminator in the sky. /dev/null is a special Unix device which goes nowhere. Nada. Nothing. Kaput. This is the end of the line

    From everything2.com
    char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
    I wear a gray hat

  8. #8
    Join Date
    Dec 2001
    Posts
    1,029
    Wow, I've never seen a file cleared out that way. I usually just do ">filename" to redirect the output of no command, which is nothing, to the file.
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

  9. #9
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,416
    But do you really want to clear out your access_logs? Either you or your clients may have numerous future needs of them.

    Why not just gzip them instead, rotate them, etc?
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  10. #10
    Join Date
    Nov 2001
    Location
    Canada
    Posts
    1,963
    i always thought it was................

    rm -f access_log
    ln -s /dev/null $PWD/access_log

    or path/to/access_log

    ??
    oh well

    I believe you can also just do rm -f logfile
    and thats it
    dont restart
    just leave it

    should be fine also

  11. #11
    I believe you can also just do rm -f logfile
    and thats it
    dont restart
    just leave it
    No . You must restart apache as it will continue to write to the files even if you think you have deleted them as they are open to the process and the space you think you have saved is not returned to the file system. A simple look at the Apache documentation shows you this :
    http://httpd.apache.org/docs/logs.html#rotation

  12. #12
    I'm looking at you guys and asking myself: isn't it easier to turn off the logs?

    Powered by AMD & FreeBSD.
    "Documentation is like sex:
    when it is good, it is very, very good;
    and when it is bad, it is better than nothing."

  13. #13
    Join Date
    Jun 2002
    Location
    Nova Scotia
    Posts
    39
    No, no it isn't.
    Pride is the match that lights the hatefires beneath us all

  14. #14
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    746
    rm -f access_log
    rm -f error_log
    apachectl graceful

    cp /dev/null access_logs
    cp /dev/null error_logs
    apachectl graceful

    Hmm, I have tried both these and my harddrives are still full.

  15. #15
    Join Date
    Nov 2001
    Location
    Ann Arbor, MI
    Posts
    2,978
    You might want to shut down apache, truncate the logs, then start apache back up.
    -Mark Adams
    www.bitserve.com - Secure Michigan web hosting for your business.
    Only host still offering a full money back uptime guarantee and prorated refunds.
    Offering advanced server management and security incident response!

  16. #16
    Originally posted by ClusterMania
    rm -f access_log
    rm -f error_log
    apachectl graceful

    cp /dev/null access_logs
    cp /dev/null error_logs
    apachectl graceful

    Hmm, I have tried both these and my harddrives are still full.
    Log rotation to process (if you want), compress or delete the logs, is best. cp is pointless, just type "echo -n > /path/to/log_file" and it will overwrite it with no content. You can also delete it and "touch" a new one. Once you restart Apache it will start logging again, so you can create a symbolic link to point the log file to /dev/null and it will not grow again (if you don't want logs).

    You can also set the directive in Apache to write the logs to /dev/null as well. Finally, the graceful command might not work, depending on your Apache build, so you might need ot execute a "start" or "startssl". Be sure to either restart, or stop and then start (or startssl). It's really that simple.
    Robert McGregor
    URL: http://www.2host.com
    Email: robertm@(nospam)2host.com

Posting Permissions

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