18 lines
416 B
Bash
18 lines
416 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
# Log rotation script for nginx and Node.js logs
|
||
|
LOG_DIR="/home/*/logs"
|
||
|
|
||
|
# Compress logs older than 3 days
|
||
|
find $LOG_DIR -name "*.log" -type f -mtime +3 -exec gzip {} \;
|
||
|
|
||
|
# Delete compressed logs older than 7 days
|
||
|
find $LOG_DIR -name "*.gz" -type f -mtime +7 -delete
|
||
|
|
||
|
# Rotate nginx logs
|
||
|
if [ -f /var/run/nginx.pid ]; then
|
||
|
kill -USR1 $(cat /var/run/nginx.pid)
|
||
|
fi
|
||
|
|
||
|
# Rotate PM2 logs
|
||
|
pm2 flush
|