2

I'm trying to make a tar of a logs directory, the applications are running so the logs keep changing, clearly when i run the tar command it give me the warning: "file changed as we read it", and give an exit status of 1, the problem is that the exit status keep being non zero (1) with the options:

--ignore-failed-read --ignore-command-error --warning=no-file-changed

There's a way to force the exit status 0?

4
  • Why do you need to tar a file while it is being changed!?
    – Khaled
    Dec 6, 2017 at 8:19
  • @Khaled running on this machine there are critical application, I'can't stop them, and between having backup and no backup, i accept the fact that having possible corrupt backup is better than nothing
    – Emax
    Dec 6, 2017 at 8:21
  • Rotate the log files immediately before the backup then backup everything bar the active log files or if you are using a filesystem that you can take snapshots of, snapshot the filesystem and backup from that.
    – user9517
    Dec 6, 2017 at 8:39
  • 2
    @Emax: Any well-written application should support log rotation. It will re-open the log files upon receiving a SIGHUP. Using logrotate, you can have your log files rotated daily, weekly, etc. Logrotate can also compress the rotated files or do whatever you want.
    – Khaled
    Dec 6, 2017 at 8:51

0

You must log in to answer this question.

Browse other questions tagged .