shell 比较文件最后修改时间与当前系统时间的时间间隔是否大于5分钟

shell脚本判断

#!/bin/bash
 
timestamp=$(date +%s)
filetimestamp=$(stat -c %Y filename)
 
#echo $timestamp
#echo $filetimestamp
#echo $[$timestamp - $filetimestamp]
 
if [ $[$timestamp - $filetimestamp] -lt 300 ];
then
command
...
else 
command 
...
fi

 -lt:小于

原文地址:https://www.cnblogs.com/John-2011/p/15237088.html