Results 1 to 18 of 18
  1. #1

    How to find and delete all log files **HELP!!**

    Does anyone know how to delete all log files, they are taking up so much diskspace and it would take forever to delete them manually so does anyone know a command I can run through SSH run to delete all log files? Something that would search server wide for *.log and delete them all, anyone know how to do that? I need to do it on a Weppliance 3.1 server if that helps. Any help would be GREATTTTTTTTTTTTTLY appericated, thanks!

  2. #2
    Join Date
    Jun 2001
    Location
    Earth
    Posts
    1,259
    find / -name *.log -print

    Should find them all. You'll need to run that as root. I would not suggest automatically deleting them. Some processes might not like you removing their log while they are running.

    Frank
    Umbra Hosting
    cPanel | Softaculous | CloudLinux | R1Soft | Ksplice
    Web Hosting, Reseller Hosting, VPS, Dedicated Servers, Colocation
    UmbraHosting.com

  3. #3
    But there is about 2,000 of them so I need something that will delete them all.... Anyone know how I can do this??

  4. #4
    Anyone know....?

  5. #5
    You can arrange the logs datewise and can delete the old logs at least.

  6. #6
    How do I do that?

  7. #7
    Join Date
    Jul 2002
    Posts
    924


    http://www.webhostingtalk.com/forumd...?s=&forumid=33

    You might want to post a request there... someone would probally do what you want for $10
    Unlimited Space & Bandwidth
    http://localhost/
    Providing hosting since 17/99/3003

  8. #8
    Join Date
    Aug 2002
    Posts
    122
    You should employ a program that automatically rotates your logs so that you will never have to face this problem again. I use newsyslog, but there are others.

    http://freshmeat.net/search/?q=newsy...ojects&x=0&y=0

    (I don't wanna be rude or anything, but if you don't know how to delete some files you shouldn't manage a UNIX 'puter.)
    Last edited by krc; 09-11-2002 at 03:32 AM.

  9. #9
    Join Date
    Dec 2001
    Location
    Ponchatoula, LA
    Posts
    497
    You could try this:

    find / -name "*.log" -exec cp --reply=yes /dev/null {} \;

    That will empty all log files instead of deleting them. Some programs, like apache, will get very cranky if you delete a log file while they are running.

    It's probably a better idea to rotate your log files as others have said. You never know when you'll have a problem and really wish you had those log files so that you can see what happened.

    Richard
    Enigma Hosting
    "I wasn't speeding, I was qualifying!"

  10. #10
    I got this...

    [root@host root]# cd ..
    [root@host /]# find /home/virtual/ -name "*.log" -exec cp --reply=yes /dev/null {} \;
    cp: unrecognized option `--reply=yes'
    Try `cp --help' for more information.
    cp: unrecognized option `--reply=yes'
    Try `cp --help' for more information.
    cp: unrecognized option `--reply=yes'
    Try `cp --help' for more information.
    cp: unrecognized option `--reply=yes'
    Try `cp --help' for more information.
    cp: unrecognized option `--reply=yes'
    Try `cp --help' for more information.
    cp: unrecognized option `--reply=yes'
    Try `cp --help' for more information.

    Any idea what's wrong..?

  11. #11
    Join Date
    Jun 2001
    Location
    Earth
    Posts
    1,259
    Try "man cp" to get the cp options. I believe you want cp -i not cp --reply=yes

    Frank
    Umbra Hosting
    cPanel | Softaculous | CloudLinux | R1Soft | Ksplice
    Web Hosting, Reseller Hosting, VPS, Dedicated Servers, Colocation
    UmbraHosting.com

  12. #12
    hmm

    dont delete all the logs
    i once delete some log and it crash my control panel
    delete just the logs of the sites
    Http.co.il - Web Hosting Solutions

  13. #13
    Join Date
    Dec 2001
    Location
    Ponchatoula, LA
    Posts
    497
    The --reply=yes was so that it wouldn't prompt for the overwrite on each file. It worked on the mandrake box I was on, but it didn't work on the red hat box I just tried. Not sure how to force it to overwrite without prompting.

    Richard
    Enigma Hosting
    "I wasn't speeding, I was qualifying!"

  14. #14
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    283
    find / -name "*.log" -exec cp -f /dev/null {} \;
    Jason Mansfield - jmansfie [at] uoguelph.ca

  15. #15
    Join Date
    Dec 2001
    Location
    Ponchatoula, LA
    Posts
    497
    I tried cp -f on a red hat box and it still prompts

    Richard
    Enigma Hosting
    "I wasn't speeding, I was qualifying!"

  16. #16
    Join Date
    Dec 2001
    Location
    Ponchatoula, LA
    Posts
    497
    Just remembered red hat does an

    alias cp='cp -i'

    so, do

    unalias cp

    then you can use

    find / -name "*.log" -exec cp /dev/null {} \;

    Richard
    Enigma Hosting
    "I wasn't speeding, I was qualifying!"

  17. #17
    Join Date
    May 2001
    Posts
    1,513
    I would

    1. cd /

    2. rm -r *.log and keep my fingers crossed.

  18. #18
    Join Date
    Aug 2002
    Location
    Denver, CO
    Posts
    331
    [edit] I did not see Noldar's post above. Thats the fix
    Last edited by Rebies; 09-13-2002 at 03:30 PM.

Posting Permissions

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