报告状态crontab行中的日志文件linux redhat中



我想知道如何提取crontab的状态。

目前,我有这些行,执行off:

crontab -l

#* * * * * cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
#* * * * * sleep 15 && curl cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
#* * * * * sleep 30 && curl cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
#* * * * * sleep 45 && curl cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh

欲望,基于这些行的crontab状态,在日志文件中向后报告或关闭。

在这种情况下,我必须报告"关闭"

而不是:

crontab -l

* * * * * cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
* * * * * sleep 15 && curl cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
* * * * * sleep 30 && curl cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
* * * * * sleep 45 && curl cd $HOME;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh

在这种情况下,我必须在"上"上报告

他们可以帮助我任何想法?

谢谢

 crontab -l | awk '{if($0~/^ *#/){ print "OFF: " $0 } else print "ON : " $0 }' 
 > cronStatusReport.$(/bin/date +%Y%m%d.%H%M)

应该产生您要寻找的输出。

output (来自数据的减少集)

OFF: #* * * * * cd /C/Users/Neil_2;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
OFF: #* * * * * sleep 15 && curl cd /C/Users/Neil_2;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
ON : * * * * * sleep 30 && curl cd /C/Users/Neil_2;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh
ON : * * * * * sleep 45 && curl cd /C/Users/Neil_2;sh .bash_profile >/dev/null 2>&1;cd /home/gisdesa/GIS/DESA;. ./loader_DESA.sh

ihth

最新更新