After Nginx has been running for a while, the files in /var/log/nginx
are:
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
The files cycle. Each day access.log.14.gz
is purged, the files are rotated, and a fresh access.log.1 is created.
Suppose I move daily the file access.log.2.gz from the server's disk to an otherwise-idle machine's disk? Is it sufficient to merely run a cron job daily to perform the move? Is there a scenario when a file or a part of a file would be corrupted or lost by running a cron job?
Update I am (now) aware that, as with many things in cloud-based development, I can solve a current and ongoing problem by simply pushing a button. But I'd like to understand a little bit more what is happening, even if at the end I will actually push the button.
So let me repeat the question. The fact that my server is indeed an AWS one is an orthogonal issue, and so for the purpose of this question: suppose that my server hardware is owned and managed by myself. Now suppose that I have a cron job running once a day on the server. The job moves, daily, access.log.2.gz
to an alternative storage away from the server—both to ensure that I do not lose that file when Nginx wraps around and to avoid flooding whatever disk I have on the server with logs.
Is there a scenario when a file or part of a file would be corrupted by running a cron job?