• 首页
  • 搜索
  • 夜间模式
    ©2026  大白蚁的生活碎碎念 Theme by OneBlog

    大白蚁的生活碎碎念博客

    搜索
    标签
    # 随笔 # 数据库 # typecho # Linux # teamspeak
  • 首页>
  • 学习>
  • 正文
  • Shell脚本,比较源文件修改时间与系统时间

    2023年07月15日 2 阅读 0 评论 315 字

    需要用到一个Shell脚本,用于对比文件修改时间与现行时间的差值,默认300秒,5分钟

    #!/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
    本文著作权归作者 [ 大白蚁 ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    — END —
    首页
    Copyright©2026  All Rights Reserved.  Load:0.016 s
    Theme by OneBlog V3.6.5
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。