免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 15352 | 回复: 19
打印 上一主题 下一主题

find 中的 -ctime 和 -mtime ,-atime 区别?  关闭 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2002-08-20 15:48 |只看该作者 |倒序浏览
请问 -ctime 和 -mtime 有什么关系 ?
如果父目录的 ctime 改变, 那它下面的文件的 ctime 就会自动都改了吗 ?
-ctime 和 -mtime ,-atime 这些信息是存在哪儿呢 ?
多谢!

论坛徽章:
0
2 [报告]
发表于 2002-08-20 16:38 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

我也想知道。

论坛徽章:
0
3 [报告]
发表于 2002-08-20 17:27 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

我用 -mtime -1 找到了新建或改的文件.
但怎样才能找到一天内 mv 来的文件呢( 它们的时间是原有的时间,早于一天 ) ?

论坛徽章:
0
4 [报告]
发表于 2002-08-21 08:20 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

用-newer选项啊。
你可以先touch一个你想要的时间的文件如下:
$ touch -t 08190800 test
$ ls -l test
-rw-r--r--   1 dba      other          0 Aug 19 08:00 test
然后
$ find . -newer test -print
.
./.sh_history
$ ls -l .sh_history
-rw-------   1 dba      other        154 Aug 20 17:39 .sh_history

用touch可以写出你想要的任何时间的文件,然后用-newer ,! -newer选项即可成功。


论坛徽章:
0
5 [报告]
发表于 2002-08-21 09:14 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

1.ctime含inode信息修改的时间.mtime只指文件内容建立或修改的时间.
2 不会.
3.这些信息应该是存在文件系统的超级块里.

论坛徽章:
0
6 [报告]
发表于 2002-08-21 11:11 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

我查了书 -ctime 是指 inode 的改变(或称文件的状态改变).
请问 inode 存了哪些信息 ?
做了些小测试,-mtime 改, -ctime 一定也改.
改文件名, -ctime 也会改.
谁能回答 i-node 存了哪些东西 ?

论坛徽章:
0
7 [报告]
发表于 2002-08-21 11:26 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

vi /usr/include/sys/inode.h

论坛徽章:
0
8 [报告]
发表于 2002-08-21 16:24 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

班主,我不能 access /usr/include/sys/inode.h .
摘书如下:
Directories contain directory entries. Each entry contains a file or subdirectory name and an index node reference number (i-node number). To increase speed and enhance use of disk space, the data in a file is stored at various locations in the computer's memory. The i-node contains the addresses used to locate all the scattered blocks of data associated with a file. The i-node also records other information about the file including time of modification and access, access modes, number of links, file owner, and file type.
可我发现 -atime 改了, -ctime 还没改. why ?
( 我先 cat 一个 ASCII 文件,再用 -atime -1 有它用 -ctime -1 居然没有它.)
着岂不跟 inode 信息改变, ctime 就改矛盾吗?

论坛徽章:
0
9 [报告]
发表于 2002-08-21 17:07 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

我不同意你贴出来的那段文章,正如我提到的那样,atime,ctime,mtime是放到超级块里,在sco unix下是一种叫stat的结构.(stat_32),不同的系统文件系统可能不同.
sco 下inode的结构如下:

typedef struct  inode
{
        struct  inode   *i_forw&#59;        /* inode hash chain */
        struct  inode   *i_back&#59;        /* '' */
        struct  inode   *av_forw&#59;       /* freelist chain */
        struct  inode   *av_back&#59;       /* '' */
        int     *i_fsptr&#59;       /* "typeless" pointer to fs dependent */
        ino32_t i_number&#59;       /* i number, 1-to-1 with dev address */
        ushort  i_ftype&#59;        /* file type = IFDIR, IFREG, etc. */
        short   i_fstyp&#59;        /* File system type */
        off_t   i_size&#59;         /* size of file */
        ushort  i_uid&#59;          /* owner */
        ushort  i_gid&#59;          /* group of owner */
        ushort  i_flag&#59;
        ushort  i_want&#59;         /* i_flag extension to avoid MP races */
        ushort  i_count&#59;        /* reference count */
        short   i_nlink&#59;        /* directory entries */
        dev_t   i_rdev&#59;         /* Raw device number */
#define         i_namtype i_rdev /* i_ftype==IFNAM subtype */
        dev_t   i_dev&#59;          /* device where inode resides */
               struct mount    *i_mton&#59;/* ptr to mount table entry that */
                                        /* this directory is mounted on */
                struct region   *i_rp&#59;  /* ptr to shared region if any */
                struct stdata   *i_sp&#59;  /* ptr to associated stream */
                struct iisem    *isem&#59;  /* ptr to XENIX  semaphores */
                struct iisd     *isd&#59;   /* ptr to XENIX shared data */
        } i_un&#59;
#define         i_mnton i_un.i_mton     /* i_ftype==IFDIR IMOUNT */
#define         i_rptr  i_un.i_rp       /* i_ftype==IFREG || i_ftype==IFBLK */
#define         i_sptr  i_un.i_sp       /* i_ftype==IFCHR || i_ftype==IFIFO */
#define         i_sem   i_un.isem       /* i_ftype==IFNAM && i_namtype==IFSEM */
#define         i_sd    i_un.isd        /* i_ftype==IFNAM && i_namtype==IFSHD */

        struct fstypsw  *i_fstypp&#59;      /* ptr to file system switch FSPTR */
        long            *i_filocks&#59;     /* pointer to filock (structure) list */
        unsigned long   i_mappages&#59;     /* number of pages currently cached */
        unsigned long   i_vcode&#59;        /* read-ahead block save (NFS) */
        short           i_wcnt&#59;         /* write open count or ITEXT count */
        struct lockb    i_cilock&#59;       /* tas to synchronize i_flag changes */
        ushort          i_rdlocks&#59;      /* count of non-exclusive lockers */
} inode_t&#59;


所以,访问一个文件不能改变inode信息.
使用chown, chgrp, chmod命令可以很好的比较mtime和ctime
chown改变一个文件的属主,用ctime可以找到,用mtime便找不到.
试试看.

论坛徽章:
0
10 [报告]
发表于 2002-08-21 19:32 |只看该作者

find 中的 -ctime 和 -mtime ,-atime 区别?

多谢斑竹! 我是在 Solaris 上面试的.我是对 -ctime 不明白.
试的结果如下:
修改文件,-mtime 改了, -ctime 也会改.
访问文件,-atime 改了, -ctime 没变.
chown, chgrp, chmod,mv, 都会使 -ctime 改变,但不影响 -atime 和 -mtime.
touch 可以改 -mtime and/or -atime,但 touch -a 只改访问时间时,-ctime也改了.
touch -m 改修改时间时,-ctime当然也改了.
好象还有别的很多东西可以令 -ctime 改变, 搞不清楚.
有什么方法可以显示 -mtime,atime,ctime 吗?
可以用 -ctime 来实现对目录的增量文件进行备份或 transfer 吗 ?
多谢!

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP