1824809 Members
4185 Online
109674 Solutions
New Discussion юеВ

inode timestamp

 
Ridzuan Zakaria
Frequent Advisor

inode timestamp

Hi,

I have a script that run everyday to reset files/directory permission to comply with our company information protection (IP) standard. The script use "chmod" as well as "find" command reset file permission. Regardless of what is the current file permission the script will attemp to reset them.

For example, the script will set "lsnrctl" file to 750 eventhough the current permission is 750.

Recently we are implementing legato incremental backup. The backup look for inode timestamp to check for changes. Unfornately "chmod" does change the inode timestamp. As a result the incremental backup become full backup due to inode timestamp got change by my IP script.

I am trying to be selective by changing only files that do not compile with IP standard using the following command. Unfortunately this commmad still change inode timestamp.

find /oracle -perm -o-w -exec chmod o-w {} \;

What command should I use perform the above task.

Any hepls is greatly appreciate.

Thanks.


quest for perfections
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: inode timestamp

There are 3 timestamps stored in each inode: 1) access time 2) modification time -- last time the CONTENTS of the file were changed 3) change time -- last time the mode, group, and/or ownership was changed. By definition, the chmod command changes the change time.

What you have to do is capture the ctime BEFORE the chmod and then restore it afterwards.



# filefixer.sh
INFILE=${1}
TDIR=${TMPDIR:-/var/tmp}
PID=${$}
REF_FILE=${TDIR}/X${PID}

touch -r ${INFILE} ${REF_FILE} # save the metadata
chmod 750 ${INFILE}
touch -c -r ${REF_FILE} ${INFILE} # restore the metadata
rm -f ${REF_FILE}

your -exec now becomes -exec filefixer.sh {} \;
This is untested but it should work. I would do this in Perl using the File::Find and stat functions.
If it ain't broke, I can fix that.
Ridzuan Zakaria
Frequent Advisor

Re: inode timestamp

Thanks.
quest for perfections