I want to update atime on large binary files

79 views Asked by At

On a list of large binary files, I want to update the atime to current time, but not affect the ctime nor mtime. (This will be an ongoing daily process).

touch -a foo 

updates the atime, but it also updates the ctime which I do not want.

head -1 foo > /dev/null 

works, but since the file is not divided by "lines", it takes a relatively long time.

The following accomplishes my goal, and works quickly even on a 400 MB file, but I am not sure if it is the best way to approach this. Any feedback is welcomed.

od foo | head -1 >/dev/null

Thanks, JimR

2

There are 2 answers

1
Srdjan Grubor On
touch -at <time> <file>

should work (works on my ext4 drive) - not sure why you would have the ctime change along with it.

0
Thomas Dickey On

Besides dd mentioned in a comment, od can read a single byte:

od -c -N 1 foo >/dev/null

Eliminating the extra head makes it a little faster.