Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

about inode information 2

Status
Not open for further replies.

RedFox4AIX

IS-IT--Management
Dec 22, 2004
24
CA
Hi , could anybody tell me is there any command in solaris to show a file 's create time, access time, and modify time just like istat in aix?
 
afaik there is no command like istat in Solaris, "ls" may give you SOME info, but not accesstime.
guessing you can get all the info by writing a small C-program using ioctl() function...

Best Regards, Franz
--
Solaris System Manager from Munich, Germany
I used to work for Sun Microsystems Support (EMEA) for 5 years in the domain of the OS, Backup and Storage
 
The find command might be able to help you out also. I know it has atime and mtime options. Not sure if that is the route you'd want to take though, if you know C daFranze's solution would probably be better.
 
Here's a quick and dirty in C. I called it [tt]filedates[/tt]...
Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>

int main(int argc, char ** argv)
{
        struct stat     filestats;

        if ( argc != 2 )
                {
                fprintf(stderr, "filedates: incorrect number of parameters!\n");
                return( -1 );
                }

        if( stat(argv[1], &filestats) )
                {
                fprintf(stderr, "filedates: Couldn't get file stats for %s!\n", argv[1]);
                return( -1 );
                }

        printf("         File Name: %s\n", argv[1]);
        printf("              Size: %ld\n", filestats.st_size);
        printf("  Last Access Time: %s", asctime(localtime(&filestats.st_atime)));
        printf("     Last Mod Time: %s", asctime(localtime(&filestats.st_mtime)));
        printf("Last Stat Chg Time: %s", asctime(localtime(&filestats.st_ctime)));

        return(0);
}
You can pretty it up as you need. It compiles with GCC with no problems.

Hope this helps.
 
great Sam, but btw. the returncodes are not POSIX conform... ;-)

Best Regards, Franz
--
Solaris System Manager from Munich, Germany
I used to work for Sun Microsystems Support (EMEA) for 5 years in the domain of the OS, Backup and Storage
 
D'oh! [surprise]

The return codes aren't POSIX compatible, but that just goes to show you the benfits of open source! [bigsmile]

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top