linux shell脚本中执行ntpclient
来源:互联网 发布:高中软件贴吧 编辑:程序博客网 时间:2024/05/22 18:02
#!/bash/sh# Program:# execute ntpclient cmd # Version: v1.0# Author: hp#function syntime() { echo "synchronizing time...." echo "server is $1" echo "execute cmd..." if test -z $1; then echo "server is $1" h="" fi if test -z $count; then echo "count is $count" c="" fi if test -z $interval; then i="" fi echo "$ntpd $h $1 $c $count $d $s $i $interval" $ntpd $h $1 $c $count $d $s $i $interval}start_time="`date +%Y%m%d`"ntpd="/home/haopeng/open_source/ntpclient-2015/ntpclient"declare -f syntimeecho "start time is $start_time"array=($@)echo ${array[*]}echo "total element count is $#"for ((i=0; i<$#; i=i+1))do sleep 1 echo ${array[i]} case ${array[i]} in "-h") i=$(($i+1)) h="-h" server=${array[i]} echo "server is ${array[i]}" ;; "-c") c="-c" i=$(($i+1)) count=${array[i]} echo "count is ${array[i]}" ;; "-i") i="-i" i=$(($i+1)) interval=${array[i]} echo "interval is ${array[i]}" ;; "-s") s="-s" ;; "-d") d="-d" ;; esacdoneecho "now time is $(date +%Y%m%d)"echo $server | grep ","if [ $? -eq 0 ]; then echo "there is muti server" server_split=${server//,/ } while [ true ] do for everyserver in $server_split do syntime $everyserver if [ $start_time != `date +%Y%m%d` ]; then echo "time is synchronized!!" fi while [ true ] do echo "check ntpclient process whether exit or not" if [ `ps -ef | grep "ntpclient" | wc -l` -eq 1 ]; then echo "ntpclient is exit.." break else echo "ntpclient is not exit and wait to continue check." sleep 1 fi done done echo "all server is polling and wait sleep 60 second.." sleep 60 doneelse echo "there is one server" syntime $serverfi
0 0
- linux shell脚本中执行ntpclient
- linux执行shell脚本
- Linux执行shell脚本
- linux 定时执行shell脚本
- linux 定时执行shell脚本
- linux 定时执行shell脚本
- linux 定时执行shell脚本
- linux 定时执行shell脚本
- linux 定时执行shell脚本
- linux执行shell脚本的
- Linux下执行Shell脚本
- linux定时执行shell脚本
- LINUX定时执行shell脚本
- Linux-Shell脚本执行方式
- Linux执行Shell脚本问题
- linux 定时执行shell脚本
- linux 定时执行shell 脚本
- Linux Shell脚本执行方式
- 不使用C/C++字符串库函数,如何自行编写strcpy()函数
- Xcode文档注释使用总结
- HDU-1864-最大销售额【背包】
- JAVA基础 -从父类的引用如何调用子类中独有的方法
- VM虚拟机中Linux扩展磁盘空间的方法
- linux shell脚本中执行ntpclient
- jzoj 1146. 危险系数(acrobat)
- 浅谈HTML知识体系
- jQuery使用ajaxSubmit()提交表单示例
- 51nod 大数乘法
- 笔记:利用易宝第三方支付实现简单支付的功能
- android数据存储
- 自定义带有删除功能的EditText
- DAY5