command to know last modified user of a file

Hi

I have below requirement.

There are set of files to be monitored for audit purpose.
Source file contains the file name and its location on server.
Need to have shell script which generate a output file which is having the details of above files ( last modified user name ,lat update date,size) if its modified in last 1 day.
This shell script runs once a in day and generate the output and will mail this to set of user.

If any one have reusable code for this please share .
Appreciate your quick help on this.

Thanks,

Hi

I need to save the owner ,size and last modified date of a files into local variables of my shell script.
So that i can write this info into a different file.

Thanks,
-Suman K

Use stat if it's available, otherwise use Perl or parse the output of ls.

Hi

Is there any command to know the last modified user of a file.

Need to use this in my shellscript.

Thanks,

Thanks for your reply......
is there any way to find the last modifed user of a file,,,

Do you mean the last user who changed some file? There is no Unix filesystem I'm aware of that stores this sort of meta-information.

Yes....my context is we have a audit requirement and need to develop shell script which generates a output with the details like
Last modified date, File Size, and User ID (for last modifier) .

Here we need to monitor only pre defined set of files not all files.

So I am developing shell script and need this command.

Please let me know is there any other way to find this.

Thanks,

Suman

OK. If you want to audit a pre defined set of files, so there is a way you can do this if your system is a Linux system and it has a kernel with the auditing infrastructure enabled ( a kernel built with CONFIG_AUDIT set to "yes"). You will need to use the auditd daemon. Have a look at this:

Linux audit files to see who made changes to a file
Linux audit files to see who made changes to a file

but this is only for Linux. If you want to do this on a different system, we will need to find another solution.

Thanks for your reply...

Our system is not Linux......

We are using IBM AIX Version 6.1.

Thanks,

Well, I don't know how you can do this on the IBM AIX, but since it's a commercial grade Unix system, I'm almost sure there is way you can do this. Unfortunately the solution to this problem is totally system dependent.

[EDIT] I found something on the IBM website:

Use auditing to track reads and writes in a file
http://www.ibm.com/developerworks/aix/library/au-audit/

I think it can help you.

1 Like

Hmm......I am looking for command of sort of thing as I am preparing a shell script...

anyway thanks for time let me check the url given by you...

I merged all three threads together. Please do not double post.

An NO: there is no one simple command line interface to audit files. You have to start a special process which records audit data. You then report against it, daily or weekly.
So, it will not be one shell script - it will require some system setup changes, and one or more scripts to report and manage auditing and audit files which can become huge. Fast.

Thanks Jim for your reply.....even i have read similar thing in link shared by pflynn.

Senior Advisor - http://www.unix.com

---------- Post updated at 08:18 PM ---------- Previous update was at 08:16 PM ----------

here is the link Use auditing to track reads and writes in a file