Changing directory timestamp when writing files

mjacobson
Posts: 204
Joined: Fri Feb 08, 2002 3:35 pm

Changing directory timestamp when writing files

Post by mjacobson »

I have a vortex scrip that is writing text files to a Unix directory. Everything is working just fine but the date time stamp of the parent directories are not getting updated. I was hoping <sysutil mkdir parents 775 $path> would do this task but it doesn't appear to be working.

So if I am writing to /home/data/files1/, I want /home & /home/data * /home/data/files1 to have the date time stamp showing today's date.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Changing directory timestamp when writing files

Post by mark »

You'll have to use some other strategy to touch those higher level directories. mkdir parents doesn't touch the directory if it already exists.
User avatar
John
Site Admin
Posts: 2625
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH

Changing directory timestamp when writing files

Post by John »

One approach would be to exec touch for each of the parent directories to update it.

Normally updating the modification time on parent directories is not desired, and only if file or directory is created or removed from the directory does that change the modification time.

Depending on what you are actually trying to achieve it may be more efficient to do something like:

find /home -type d -mtime -1

to find directories with new files in the last day rather than updating attributes on several directories for every write.
John Turnbull
Thunderstone Software