Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
e5ab418c
Commit
e5ab418c
authored
Aug 03, 2022
by
Dominik Hebeler
Browse files
truncating logs
parent
a6deb4b3
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
metager/app/Console/Commands/TruncateLogs.php
0 → 100644
View file @
e5ab418c
<?php
namespace
App\Console\Commands
;
use
Illuminate\Console\Command
;
class
TruncateLogs
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'logs:truncate'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Truncates Logs that should only be kept for a day'
;
/**
* Execute the console command.
*
* @return int
*/
public
function
handle
()
{
$log_files
=
[
\
storage_path
(
"logs/metager/bv_fail.csv"
),
\
storage_path
(
"logs/metager/captcha_show.csv"
),
\
storage_path
(
"logs/metager/captcha_solve.csv"
),
];
foreach
(
$log_files
as
$log_file
)
{
if
(
\
file_exists
(
$log_file
)
&&
\
is_writable
(
$log_file
))
{
$fp
=
fopen
(
$log_file
,
"r+"
);
try
{
ftruncate
(
$fp
,
0
);
}
finally
{
fclose
(
$fp
);
}
}
}
return
0
;
}
}
metager/app/Console/Kernel.php
View file @
e5ab418c
...
...
@@ -20,6 +20,7 @@ class Kernel extends ConsoleKernel
$schedule
->
command
(
'requests:gather'
)
->
everyFifteenMinutes
();
$schedule
->
command
(
'requests:useragents'
)
->
everyFiveMinutes
();
$schedule
->
command
(
'logs:gather'
)
->
everyMinute
();
$schedule
->
command
(
'logs:truncate'
)
->
daily
()
->
onOneServer
();
$schedule
->
command
(
'spam:load'
)
->
everyMinute
();
$schedule
->
command
(
'load:affiliate-blacklist'
)
->
everyMinute
();
$schedule
->
command
(
'affilliates:store'
)
->
everyMinute
()
...
...
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