Whether monitoring file updates

shell script:

#! /bin/sh
file_path=/root/airflow/scheduler.log
check_time=120
file_old_stat="`stat ${file_path}|grep Size`"
sleep ${check_time}
file_new_stat="`stat ${file_path}|grep Size`"
if [[ `echo ${file_old_stat}` == `echo ${file_new_stat}` ]]; then
. /data/venv/bin/activate && supervisorctl restart airflow_scheduler

be

Regular tasks:

*/2 * * * * /bin/sh /hongfeng/script/monitor_scheduler.sh >/dev/null 2>&1

 

python script:

# - * - Coding: UTF-. 8 - * -
Import OS
Import Time
File = '/ the root / Airflow / the Scheduler.log'
the atime = os.path.getatime (File) # output last access time 1318921018.0
the ctime = the os.path. getctime (file) # output file creation time
mtime = os.path.getmtime (file) # output last modification time
ntime = time.time ()
the Timed = ntime-mtime
TIMEF = "notime:% S, mtime:% S, the Timed :% d "% (time.strftime ( "% Y-% m-% d% H:% M:% S ", time.localtime (ntime)), time.strftime ("% Y-% m-% d H%:% M:% S ", time.localtime (the ctime)), Timed)
Print (TIMEF)

 

Guess you like

Origin www.cnblogs.com/hongfeng2019/p/11448116.html