Example for NGINX web server logs:
cp /log/nginx/error.log /data_local/tmp_nginx_log/nginx_error_`date +"%Y_%m_%d"`.log; truncate -s0 /log/nginx/error.log; kill -USR1 $( cat /var/run/nginx.pid )
kill -HUP $( cat /var/run/nginx.pid )
Example for APACHE web server logs:
tail -n 1000 error_php_apache.log > error_php_apache.log.tmp && mv -f error_php_apache.log.tmp error_php_apache.log && /etc/init.d/httpd gracefulor simpler way:
tail -n 1000 apache-error.log > apache-error.1.log && truncate -s 1M apache-error.log && service apache2 graceful
Get first 1000 lines from all *.log files and store them all in /log/all_logs
find /log -name "*.log" -type f | xargs tail -n 1000 2>&1 | tee /log/all_logs
No comments:
Post a Comment