April 12

0 comments

Update IBM i IFS Objects Data Change Timestamp

By NickLitten

April 12, 2019

IBM i OS, IFS, java

An interesting question was lobbed at me this morning – “How can I change the data change timestamp in an ifs file?”

One of the good folks over at Tire Rack (the software developers, not the blokes that change the tires) asked if I knew a way to update the timestamp for the data changed value in an IFS file when it was copied.

The problem is that when the IFS CPY command is used, it creates a new copied file and updates the Create, Last Access and Attribute Change Date and Time values but because the data in the copied IFS file has not changed – the Data Change date/time value remains unchanged.

Creation date/time . . . . . . . . . . :   04/11/19  12:13:08
Last access date/time  . . . . . . . . :   04/11/19  01:01:47
Data change date/time  . . . . . . . . :   03/29/19  10:50:07
Attribute change date/time . . . . . . :   04/11/19  12:13:08

A little head scratching, messaging back and forth and trying things like change IFS object authority, we realised that the Data change value only changes when the actual data in the file is changed. *duh

Example of COPYING an IFS file without changing the Data

If we take a sample IFS file that is living in my home directory. We can see the attributes look like this:

Object . . . . . . :   /home/LITTENN/TRNX01API.txt           
Creation date/time . . . . . . . . . . :   03/26/19  12:39:15
Last access date/time  . . . . . . . . :   04/11/19  01:01:47
Data change date/time  . . . . . . . . :   03/29/19  10:50:07
Attribute change date/time . . . . . . :   03/29/19  10:50:07

When I copy this file to a new file using:

CPY OBJ('/home/LITTENN/TRNX01API.txt') TOOBJ(anewfile.txt)         

It looks like this:

Object . . . . . . :   /home/LITTENN/anewfile.txt                
Creation date/time . . . . . . . . . . :   04/11/19  14:03:55   
Last access date/time  . . . . . . . . :   04/11/19  01:01:47   
Data change date/time  . . . . . . . . :   03/29/19  10:50:07   
Attribute change date/time . . . . . . :   04/11/19  14:03:55   

As you can see, all the dates have been reset to the new files creation timestamp but the data change remains the same.

I recommended writing some code to open/read/save the file to flag the data as changing but within a few minutes he had found an even better solution: TOUCHING the file does the trick.

STRQSH CMD('touch /home/littenn/anewfile.txt')   

Which gives us:

Object . . . . . . :   /home/LITTENN/anewfile.txt            
Creation date/time . . . . . . . . . . :   04/11/19  14:03:55
Last access date/time  . . . . . . . . :   04/11/19  14:05:33
Data change date/time  . . . . . . . . :   04/11/19  14:05:33
Attribute change date/time . . . . . . :   04/11/19  14:05:33

We can take this one step further with the -t flag.

With this command, you can change the access time of a file by determining a specified time to it. It will modify the time by specified time instead of default time.

touch -t
YYYYMMDDhhmm.ss  
STRQSH CMD('touch -t 201906250101.01 /home/littenn/anewfile.txt')  
Object . . . . . . :   /home/LITTENN/anewfile.txt            
Creation date/time . . . . . . . . . . :   04/11/19  14:03:55
Last access date/time  . . . . . . . . :   06/25/19  01:01:01
Data change date/time  . . . . . . . . :   06/25/19  01:01:01
Attribute change date/time . . . . . . :   04/11/19  14:07:24

Pretty Cool.

Big Thanks to the good IT Folks of Tire Rack, Michael Ringler and Dale Shreve, for this cool tip.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

>