LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: home

怎么知道一个文件被读取了多少次?

[复制链接]
 楼主| 发表于 2003-11-19 20:18:14 | 显示全部楼层
请大家看看有什么错没?还有,怎么可以命令后带一个参数呢?
现在只能监视/etc/passwd
发表于 2003-11-19 20:25:53 | 显示全部楼层
stat
发表于 2003-11-19 20:27:26 | 显示全部楼层
這功能有點不切?際啊, 要在web 下?作沒什麼但shell 下便~~;
发表于 2003-11-20 00:15:54 | 显示全部楼层
提高人气么,都在钻研这种“屠龙之技”,呵呵
 楼主| 发表于 2003-11-20 01:53:11 | 显示全部楼层
行了。谢谢你们!!
R# cat cataccess
#!/bin/bash
count=0
time_old=`ls -lu /etc/passwd|awk '{print $6,$7.$8}'`
while true; do
time_now=`ls -lu /etc/passwd|awk '{print $6,$7,$8}'`
if [[ ${time_now} != ${time_old} ]] ; then
count=$(($count + 1))
time_old=${time_now}
fi
if [[ $count == 2 ]];then echo "the file already access over 2 time";exit 0;fi
sleep 60
done

R# ./cataccess
the file already access over 2 time
R#
在另一个终端每隔62秒不断的cat /etc/passwd,缺点就是精确是时间是一分钟,也太久了吧,能到秒就好了。 还有更多的方法吗?com on,every body~~~
发表于 2003-11-20 02:38:22 | 显示全部楼层
connect,CU上的精灵
发表于 2003-11-20 08:32:48 | 显示全部楼层
用ls --full-time就可以精确到秒
 楼主| 发表于 2003-11-20 12:47:15 | 显示全部楼层
最初由 r2007 发表
用ls --full-time就可以精确到秒


谢谢!我要最后访问的时间,精确到秒
发表于 2003-11-20 12:59:40 | 显示全部楼层
ls -u --full-time
 楼主| 发表于 2003-11-20 13:32:38 | 显示全部楼层
最初由 r2007 发表
ls -u --full-time


谢谢~~~我笨。。。

现在能精确到秒了。还有什么错误清大家指出来。。。。。。。。

########code
#!/bin/bash
count=0
time_old=`ls -u --full-time /etc/passwd|awk '{print $6,$7,$8}'`
while true; do
time_now=`ls -u --full-time /etc/passwd|awk '{print $6,$7,$8}'`
if [[ ${time_now} != ${time_old} ]] ; then
count=$(($count + 1))
time_old=${time_now}
fi
if [[ $count == 2 ]];then echo "the file already access over 2 time";exit 0;fi
sleep 0.1
done
#end


再问问,那后面那么多000000000,还有 +0800 是什么意思?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表