From 22ad94b336cb71dd4a0ed37837abfd684fd78356 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 14 Dec 2022 17:35:48 +0800 Subject: [PATCH] check time synchronize --- script/env_check.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/script/env_check.sh b/script/env_check.sh index 2d81390f7..b4af71d95 100644 --- a/script/env_check.sh +++ b/script/env_check.sh @@ -1,12 +1,25 @@ #!/usr/bin/env bash source ./style_info.cfg +echo -e "check time synchronize................................" +t=`curl http://time.akamai.com/?iso -s` +t1=`date -d $t +%s` +t2=`date +%s` +let between=t2-t1 +if [[ $between > 10 ]] || [[ $between < -10 ]]; then + echo -e ${RED_PREFIX}"Warning: The difference between the iso time and the server's time is too large: "$between"s" ${COLOR_SUFFIX} +else + echo -e ${GREEN_PREFIX} "ok: Server time is synchronized " ${COLOR_SUFFIX} +fi + + + echo -e "check login user........................................" user=`whoami` if [ $user == "root" ] ; then - echo -e ${GREEN_PREFIX} "ok: login user is root" ${COLOR_SUFFIX} + echo -e ${GREEN_PREFIX} "ok: login user is root" ${COLOR_SUFFIX} else - echo -e ${RED_PREFIX}"Warning: The current user is not root "${COLOR_SUFFIX} + echo -e ${RED_PREFIX}"Warning: The current user is not root "${COLOR_SUFFIX} fi