Is it possible to set ctime of a file to a desired value. I am working on a restore script and I need to set the ctime of the file to a previous timestamp after restoring the file.
I tried touch
function, but it only sets the atime and mtime.
Is it possible to set ctime of a file to a desired value. I am working on a restore script and I need to set the ctime of the file to a previous timestamp after restoring the file.
I tried touch
function, but it only sets the atime and mtime.
You cannot change the ctime by ordinary means. This is by design:
The ctime is always updated to the current when you change any of the file's metadata, and there is no way to impose a different ctime.
To change the ctime of a file, you can:
ctime
is the inode or file change time. Thectime
gets updated when the file attributes are changed, like changing the owner, changing the permission or moving the file to an other filesystem but will also be updated when you modify a file.
So you need to perform any of these modifications to a file to change the ctime
.