I have two commands that I usually use to truncate log files but the issue is the first one will completely truncate it and the second one works only on one file at the time.
find /path/to/log/directory -name *log -exec cp /dev/null '{}' \;
echo "$(tail -1000 /home/username/public_html/error_log)" > /home/username/public_html/error_log
I need command that will work on multiple log files at once and truncate it so that last 1000 lines will stay in those log files.
Thanks :cheers:
A simple command for doing this should be:
This command searches for all .log files in the current directory and truncates them by keeping only the last 1000 lines.