ubuntu - 每天将 Nginx 日志移出服务器是否可能导致损坏?

标签 ubuntu nginx cron

Nginx 运行一段时间后,/var/log/nginx 中的文件是:

Dec 17 access.log.1
Dec 16 access.log.2.gz
Dec 15 access.log.3.gz
Dec    ..
Dec  5 access.log.13.gz
Dec  4 access.log.14.gz

文件循环。每天access.log.14.gz被清除,文件被轮换,并创建一个新的 access.log.1。

假设我每天将文件 access.log.2.gz 从服务器磁盘移动到其他空闲机器的磁盘?每天只运行一个 cron 作业来执行移动就足够了吗?是否存在文件或文件的一部分因运行 cron 作业而损坏或丢失的情况?

更新
我(现在)意识到,与基于云的开发中的许多事情一样,我可以通过简单的 pushing a button 来解决当前和持续存在的问题。 .但我想更多地了解正在发生的事情,即使最后我真的会按下按钮。

所以让我重复这个问题。我的服务器确实是 AWS 的事实是一个正交问题,因此出于这个问题的目的:假设我的服务器硬件由我自己拥有和管理。现在假设我有一个每天在服务器上运行一次的 cron 作业。工作每天都会变动,access.log.2.gz到远离服务器的替代存储——既要确保当 Nginx 环绕时我不会丢失该文件,又要避免用日志淹没服务器上的任何磁盘。

是否存在因运行 cron 作业而损坏文件或文件的一部分的情况?

最佳答案

您可能想探索 AWS cloudwatch 代理以将您的日志存储在 cloudwatch 中。

CloudWatch includes a new unified agent that can collect both logs and metrics from EC2 instances and on-premises servers. If you are not already using the older CloudWatch Logs agent, we recommend that you use the newer unified CloudWatch agent.



如果您希望在 S3 上存储副本,您可以轻松配置 AWS Cloudwatch 日志组以将日志复制到 S3

来源:Quick Start: Install and Configure the CloudWatch Logs Agent on a Running EC2 Linux Instance

You can export log data from your log groups to an Amazon S3 bucket and use this data in custom processing and analysis, or to load onto other systems.



Exporting Log Data to Amazon S3

关于ubuntu - 每天将 Nginx 日志移出服务器是否可能导致损坏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59384905/

相关文章:

nginx tcp 流 (k8s) - 在上游关闭时保持客户端连接打开

node.js - 带 Node 的Nginx服务器返回js代码

php - 为某些网站切换 nginx php 版本

php - bash 脚本从命令行运行,但不是从 cron 运行

php - 使用 CPanel 在 cron 作业中运行 PHP 文件

c++ - 框架管理库

linux - Chrome 突然放大了 ubuntu

mysql - 如何从 Ubuntu 终端读取一组字符串并将该值插入 MySQL

android - Android Studio Aidl缺少Ubuntu 15

google-app-engine - Google 应用程序引擎错误 0kb AppEngine-Google