tar: don't change date if file is the same

I’m using tar to extract files during a deployment process. I’ve noticed that systemctl issues a warning that daemon-reload must be run if a .service file has its timestamp changed, even if the file contents remain the same.

How can I configure tar to not change the file date if the file contents are unchanged?

Asked By: mustafa.0x

||

That’s not a feature any implementation of tar that I’m aware of has (they all extract in place directly; at no point the content of an existing file is considered). The point is that the file actually is getting completely overwritten, even if just with the same content it had before.

So, there’s no way to achieve that with tar alone.

If you can extract to a temporary directory first, and then use rsync to copy over only the files with changes, that would be different. However, note that this needs additional storage and night take significantly longer, depending on the temporary storage.

issues a warning

So, a warning is a warning, not a problem. If you know nothing has changed, ignore it. But if nothing has changed, rubbing the daemon reload has no adverse effect, either.

Answered By: Marcus Müller
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.