Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ISPConfig 3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
494
Issues
494
List
Boards
Labels
Service Desk
Milestones
Merge Requests
32
Merge Requests
32
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ISPConfig
ISPConfig 3
Commits
3dfecb0a
Commit
3dfecb0a
authored
May 18, 2018
by
Till Brehm
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'stable-3.1' into 'stable-3.1'
Stable 3.1 See merge request
ispconfig/ispconfig3!783
parents
caeab8c0
fe8ea3f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
23 deletions
+31
-23
server/lib/classes/cron.d/200-logfiles.inc.php
server/lib/classes/cron.d/200-logfiles.inc.php
+31
-23
No files found.
server/lib/classes/cron.d/200-logfiles.inc.php
View file @
3dfecb0a
...
...
@@ -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)
...
...
@@ -168,25 +175,26 @@ class cronjob_logfiles extends cronjob {
// Rotate the ispconfig.log file
//######################################################################################################
// rotate the ispconfig.log when it exceeds a size of 10 MB
$logfile
=
$conf
[
'ispconfig_log_dir'
]
.
'/ispconfig.log'
;
if
(
is_file
(
$logfile
)
&&
filesize
(
$logfile
)
>
10000000
)
{
exec
(
"gzip -c
$logfile
>
$logfile
.1.gz"
);
exec
(
"cat /dev/null >
$logfile
"
);
}
// rotate the cron.log when it exceeds a size of 10 MB
$logfile
=
$conf
[
'ispconfig_log_dir'
]
.
'/cron.log'
;
if
(
is_file
(
$logfile
)
&&
filesize
(
$logfile
)
>
10000000
)
{
exec
(
"gzip -c
$logfile
>
$logfile
.1.gz"
);
exec
(
"cat /dev/null >
$logfile
"
);
}
$num
=
10
;
// rotate the auth.log when it exceeds a size of 10 MB
$logfile
=
$conf
[
'ispconfig_log_dir'
]
.
'/auth.log'
;
if
(
is_file
(
$logfile
)
&&
filesize
(
$logfile
)
>
10000000
)
{
exec
(
"gzip -c
$logfile
>
$logfile
.1.gz"
);
exec
(
"cat /dev/null >
$logfile
"
);
$ispconfig_logfiles
=
array
(
'ispconfig.log'
,
'cron.log'
,
'auth.log'
);
foreach
(
$ispconfig_logfiles
as
$ispconfig_logfile
)
{
$ispconfig_logfile
=
escapeshellcmd
(
$conf
[
'ispconfig_log_dir'
]
.
'/'
.
$ispconfig_logfile
);
// rename older files (move up by one)
while
(
$num
>=
1
&&
is_file
(
$ispconfig_logfile
.
'.'
.
$num
.
'.gz'
))
{
rename
(
$ispconfig_logfile
.
'.'
.
$num
.
'.gz'
,
$ispconfig_logfile
.
'.'
.
(
$num
+
1
)
.
'.gz'
);
$num
--
;
}
// compress current logfile
if
(
is_file
(
$ispconfig_logfile
))
{
exec
(
"gzip -c
$ispconfig_logfile
>
$ispconfig_logfile
.1.gz"
);
exec
(
"cat /dev/null >
$ispconfig_logfile
"
);
}
// remove older logs
while
(
is_file
(
$ispconfig_logfile
.
'.'
.
$num
.
'.gz'
))
{
@
unlink
(
$ispconfig_logfile
.
'.'
.
$num
.
'.gz'
);
$num
++
;
}
}
//######################################################################################################
...
...
Write
Preview
Markdown
is supported
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