LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Clear All LOG Files (https://www.linuxquestions.org/questions/linux-server-73/clear-all-log-files-4175412856/)

Kramerica 06-22-2012 11:49 AM

Clear All LOG Files
 
Hello. Is there a way from the command line to clear all log files (*.log and *_log)? I am in the process of moving several sites to a new server and the log files, which will be maintained on the old server, are huge. Thanks

OS - Centos 5

harry edwards 06-22-2012 11:58 AM

Assuming clear means remove and not empty. The find command would do it e.g.

Code:

find /some/location -type f -name "*.log" -exec rm {} \;

Ghostwheel 06-22-2012 12:19 PM

or if you do mean to just empty them

Code:

find /some/location -type f -name "*.log" -exec cat /dev/null > {} \;


All times are GMT -5. The time now is 07:18 PM.