Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Helmo
ISPConfig 3
Commits
10eb2f3b
Commit
10eb2f3b
authored
May 18, 2018
by
Florian Schaal
Browse files
rotate error.log daily (Fixes #5003)
parent
34988378
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/lib/classes/cron.d/200-logfiles.inc.php
View file @
10eb2f3b
...
...
@@ -137,11 +137,18 @@ class cronjob_logfiles extends cronjob {
}
}
// rotate and compress the error.log when it exceeds a size of 10 MB
$logfile
=
escapeshellcmd
(
$rec
[
'document_root'
]
.
'/'
.
$log_folder
.
'/error.log'
);
if
(
is_file
(
$logfile
)
&&
filesize
(
$logfile
)
>
10000000
)
{
exec
(
"gzip -c
$logfile
>
$logfile
.1.gz"
);
exec
(
"cat /dev/null >
$logfile
"
);
// rotate and compress the error.log
$error_logfile
=
escapeshellcmd
(
$rec
[
'document_root'
]
.
'/'
.
$log_folder
.
'/error.log'
);
// rename older files (move up by one)
$num
=
$log_retention
;
while
(
$num
>=
1
&&
is_file
(
$error_logfile
.
'.'
.
$num
.
'.gz'
))
{
rename
(
$error_logfile
.
'.'
.
$num
.
'.gz'
,
$error_logfile
.
'.'
.
(
$num
+
1
)
.
'.gz'
);
$num
--
;
}
// compress current logfile
if
(
is_file
(
$error_logfile
))
{
exec
(
"gzip -c
$error_logfile
>
$error_logfile
.1.gz"
);
exec
(
"cat /dev/null >
$error_logfile
"
);
}
// delete logfiles after x days (default 30)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment