php - Laravel - 将控制台输出写入日志文件
问题描述
我有一个输出一些行的命令:
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->line('');
$this->info('--------------------------------------------------------');
$this->info('----------------- Compress documents -------------------');
$this->info('--------------------------------------------------------');
$this->line('');
$progressBar = $this->output->createProgressBar(3);
$this->info('Selecting files...');
// ...
$progressBar->advance();
$this->info('Processing...');
// ...
$progressBar->advance();
$this->info('Moving files...');
// ...
$progressBar->advance();
$this->info('--------------------------------------------------------');
$this->info('------------------------ Result ------------------------');
$this->info('--------------------------------------------------------');
// ...
$this->info('Output quality: '.$resolution.'%');
$this->info('Processed files: '.sizeof($files));
$this->info('Original size: '.number_format($originalPathSize, 3).'MB');
$this->info('Compressed size:'.number_format($compressedPathSize, 3).'MB');
$this->info('Improvement: '.number_format($compressedPathSizeDiff, 3).'MB ('.number_format($compressedPathSizeDiffPercent, 3).'%)');
$this->info('Total time: '.$timeFormatted);
// ...
$this->table($headers, $rows);
$this->info('Ready!');
}
它就像一个魅力。
问题是现在我需要在生产服务器中运行这个命令(通过 SSH),并且处理所有文件必须花费几个小时。显然,我不想在此期间保持登录状态以查看控制台输出。
正如调度任务所做的那样,有一些方法可以“自动”将控制台命令输出写入日志文件?
解决方案
推荐阅读
- javascript - 如何从不同来源的 CORS 中获取数据?
- python - Python 请求错误('Connection aborted.', OSError(0, 'error'))和规模的连接超时
- php - Laravel 5.8 尝试从数据库中查询阿拉伯语记录
- vue.js - Vuex mapMutations 没有按预期工作
- hadoop - 如何找到 Parquet 文件生成时使用的 COMPRESSION_CODEC?
- python-3.x - 如何找到端口号
- android - 升级到 PI 期间是否保留了 Android 密钥库?
- spring - 在 2 个 JPATransactionManager 类和 DataSourceUtils 之间等待 15 分钟
- c# - 需要从表中选择一个值并将其存储到变量中
- python - How to use selenium to click on date symbol and enter dates?