判断Linux环境下文件是否还在变化的脚本
来源:互联网 发布:地瓜干 知乎 编辑:程序博客网 时间:2024/06/14 16:23
###############################################
# Name:check_file_status.sh
# Author:cdshrewd (cdshrewd#163.com)
# Purpose:Check wether file is changing or not.
# Usage:
# Run this scripts with 2 args.
# The first one is the file full path.
# The second one is the interval between two check time.This is optional.
# You can run this scripts like './check_file_status.sh /tmp/test.txt 3'.
# Modified Date:2017/07/30
###############################################
#!/bin/bash
set -x
check_files_status()
{
fname=$1
interval=3
if [ -n $2 ]; then
len=`echo "$2"|sed 's/[0-9]//g'|sed 's/-//g'`
if [ -z $len ]; then
interval=$2
fi
fi
if [ -f "$fname" ]
then
match_cnt=0
fsize=`ls -l $fname|awk '{print $5}'`
ctime=`ls -lc $fname|awk '{print $(NF-1)}'`
for ((i=0; i<=3 ; i++))
do
cur_ctime=`ls -lc $fname|awk '{print $(NF-1)}'`
cur_fsize=`ls -l $fname|awk '{print $5}'`
if [[ "$ctime" = "$cur_ctime" && "$fsize" -eq "$cur_fsize" ]]; then
ctime=$cur_ctime
fszie=$cur_fsize
let match_cnt+=1;
sleep $interval
fi
done
if [ $match_cnt -eq 4 ]; then
exit 0
else
exit 1
fi
else
echo "$fs is not a file."
exit 1
fi
}
check_files_status $1 $2
- 判断Linux环境下文件是否还在变化的脚本
- linux环境下文件的类型
- linux环境下文件的操作
- linux下文件同步脚本
- linux检测目录下文件变化
- 判断指定路径下文件是否存在
- linux下文件的一些特性的判断方法
- Linux环境下文件权限的简单分析
- Linux下文件及目录是否存在
- 在linux系统下文件和数据库的定时备份
- Linux下文件的备份
- LINUX下文件的基本概念
- Linux下文件的操作
- Linux下文件的操作
- linux下文件的解压
- Linux下文件的操作
- Linux下文件的权限
- linux下文件的权限
- ORA-12012: error on auto execute of job "SYS"."BSLN_MAINTAIN_STATS_JOB" ORA-01950: no privileges on
- 事务
- HDU 6052 To my boyfriend(分块+容斥原理+单调栈)
- c#变量未赋值
- C语言 冒泡排序算法
- 判断Linux环境下文件是否还在变化的脚本
- Context namespace element xxx and its parser class [org.springframework.context.annotat Dubbo
- POJ1743 Musical Theme(后缀数组,高度数组分组)
- 不同服务器数据库之间的数据操作
- python的map函数使用
- Hessian源码分析之设计模式篇(八)
- [AOP] 7. 一些自定义的Aspect
- rabbitmq-c++(SimpleAmqpClient) 笔记代码三
- Java中abstract 类总结