确定Shell脚本中文件的年龄 [英] Determining age of a file in shell script
问题描述
G'day,
我需要查看某个特定文件距sh shell脚本的时间是否超过58分钟.我说的是带有一些POSIX扩展的普通Solaris Shell.
I need to see if a specific file is more than 58 minutes old from a sh shell script. I'm talking straight vanilla Solaris shell with some POSIX extensions it seems.
我已经考虑过要
touch -t YYYYMMDDHHmm.SS /var/tmp/toto
时间戳是58分钟前,然后执行
where the timestamp is 58 minutes ago and then doing a
find ./logs_dir \! -newer /var/tmp/toto -print
我们需要对使用镜像从各种服务器上检索到的一些日志文件进行后处理.等待文件稳定是该团队确定镜像是否完成的方式,因此当天的日志现在已完成并可以进行处理.
We need to postprocess some log files that have been retrieved from various servers using mirror. Waiting for the files to be stable is the way this team decides if the mirror is finished and hence that day's logs are now complete and ready for processing.
感谢收到任何建议.
欢呼
推荐答案
您可以在find命令中使用其他单位,例如:
You can use different units in the find command, for example:
find . -mtime +0h55m
将返回所有修改日期早于55分钟的文件.
Will return any files with modified dates older than 55 minutes ago.
这篇关于确定Shell脚本中文件的年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!