我想根据脚本 crontab 运行时间戳检查我的脚本昨晚是否在 Linux 实例上运行(或上次运行时间戳)。
那么如何获取 Linux 实例上脚本上次运行的时间?
最佳答案
我建议更好地记录脚本开始时的开始时间和脚本结束时的结束时间。
# Start Time Entry
echo "Start : " $(date +%T) > exec.log
start=`date +%s`
CALL YOUR SCRIPT HERE
# End Time Entry
end=`date +%s`
echo "End : " $(date +%T) >> exec.log
# Get the Runtime
runtime=$((end-start))
echo "Runtime: $runtime" >> exec.log
如果有更好的方法,我也很想看看并实现。
关于linux - 如何检查Linux实例中任何脚本的最后运行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58769196/