Commit e5ab418c authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

truncating logs

parent a6deb4b3
<?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;
}
}
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment