-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlogrotate.sh
More file actions
executable file
·26 lines (23 loc) · 843 Bytes
/
logrotate.sh
File metadata and controls
executable file
·26 lines (23 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# +----+----+----+----+
# | | | | |
# Author: Mark David Scott Cunningham | M | D | S | C |
# +----+----+----+----+
# Created: 2013-12-18
# Updated: 2014-04-16
#
#
#!/bin/bash
## Create date/time string
datetime=$(date +%Y.%m.%d_%H)
## Get list of secondary domains, and then compress, rename and create new error.log files
for website in $(for sitedir in */html; do echo $sitedir | cut -d/ -f1; done); do
for file in error.log transfer.log; do
mv var/$website/logs/$file var/$website/logs/${file}-$datetime;
gzip var/$website/logs/${file}-$datetime;
done;
done;
## If php-fpm then compress, rename, and create new error.log files
if [[ -f var/php-fpm/error.log ]]; then
mv var/php-fpm/error.log var/php-fpm/error.log-$datetime
gzip var/php-fpm/error.log-$datetime;
fi;