Utime Command

Hello !

Do you have any example of the utime command ?
I'm trying to change the time of last change of a file to a defined time.

Thanks.

utime() is a system call. Since we are in the shell programming forum, here is an example of the "touch" command. Try these commands:

touch -m -t 200012312359.59 data.for.2000
ls -l data.for.2000
ls -lu data.for.2000
ls -lc data.for.2000

Here we set the mtime for the file to the last second of the year 2000. This is how we set set the modification time of file to any date/time that we want. But we can't do that to the change time aka ctime.

mtime (modification time) is when the data in the file was last modified. You can set this to whatever you want by using utime(2) or touch(1).

ctime (change time) is when the last change of any happened to the file or the data it contains.

There is also a atime which is when the file was last read. We can set that to any value as well.

It works great ! Thank you !

But now, I'm facing another problem : when doing ls -ltr filename to obtain the time, I don't have the seconds....
Do you know how to obtain that ?

Thanks.

If you are using GNU ls you can use the '--full-time' option to include seconds in the output.