You can use touch -a option to modify only the access time of a file in Linux.
Example:
Create a new file:
1 2 |
## Create a new file touch myfile |
Get the file Access time
1 2 3 4 5 6 7 8 9 10 |
## Get the file Access time stat myfile ## returns ## File: myfile ## Size: 359 Blocks: 0 IO Block: 512 regular file ## Device: 2h/2d Inode: 116530640358219095 Links: 1 ## Access: (0644/-rw-r--r--) Uid: ( 1000/ debjeet) Gid: ( 1000/ debjeet) ## Access: 2022-02-02 15:21:45.148665400 +0530 ## Modify: 2022-02-02 15:21:45.148665400 +0530 ## Change: 2022-02-02 15:21:45.148665400 +0530 |
Update the file access time only
1 2 |
## Update the file access time only touch -a myfile ## changes file access time |
Get the file Access time
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
## Get the file Access time stat myfile ## returns ## File: myfile ## Size: 359 Blocks: 0 IO Block: 512 regular file ## Device: 2h/2d Inode: 116530640358219095 Links: 1 ## Access: (0644/-rw-r--r--) Uid: ( 1000/ debjeet) Gid: ( 1000/ debjeet) ## Access: 2022-02-02 18:24:29.580924200 +0530 ## Modify: 2022-02-02 15:21:45.148665400 +0530 ## Change: 2022-02-02 18:24:29.580924200 +0530 rm myfile |
Observe myfile Access time has been changed.