Prevent unrar from Updating Archive Access Time

When extracting files with unrar, the underlying operating system automatically updates the archive file's access time (atime) because the file is opened and read. Because unrar does not feature a dedicated command-line flag to request the kernel bypass atime updates (such as setting the O_NOATIME file open flag), preventing this change requires either restoring the original access time after extraction or configuring the filesystem to avoid logging read access.

Method 1: Restore the Timestamp with a Wrapper Script

The most reliable approach across standard user permissions is to capture the archive's access time prior to running unrar and restore it immediately after the process finishes.

You can run the following one-line shell command:

ARCHIVE="archive.rar"
ATIME=$(stat -c %x "$ARCHIVE") && unrar x "$ARCHIVE" && touch -a -d "$ATIME" "$ARCHIVE"

How this works:

  1. stat -c %x "$ARCHIVE" retrieves the exact last access timestamp of the file.
  2. unrar x "$ARCHIVE" extracts the contents.
  3. touch -a -d "$ATIME" "$ARCHIVE" reapplies the saved access timestamp to the archive file without altering the modification time (mtime).

Method 2: Mount the Filesystem with noatime

If you routinely process archives and have administrative access, you can prevent the operating system from updating access times globally on the storage volume.

To remount a partition with noatime:

sudo mount -o remount,noatime /path/to/mountpoint

To make this permanent, edit /etc/fstab and append noatime to the mount options for the target partition. When noatime is active, no read operations, including those performed by unrar, will modify the archive's access timestamp.

Note on unrar -ts Switches

The unrar utility provides the -ts switch (for example, -tsa-), but this controls the preservation and restoration of timestamps for the extracted contents inside the archive, not the .rar file itself on the host system. File read operations on the archive container remain governed by the operating system kernel.