Linux Windows Timer modifies system time

Source: Internet
Author: User

#/bin/bash#befortime=02:00aftertime=08:00befortime=$ (echo  $beforTime  | awk -F :  {' print $1 '}) aftertime=$ (echo  $afterTime  | awk -f : {' print $1 ') Flag=0while truedo     sleep 2s    echo  "date: $ (date +"%y-%m-%d  %h:%m:%s ")"     if [ $ (date +%h)  -eq  $beforTime  ];  then        curdate=$ (date +%d)          changedate=$ (expr  $CurDate  - 1)          date -s  ' $ (date + "%y-%m-$ChangeDate  %h:%m:%s")          if [ $? -eq 0 ]; then             echo  "changed date: $ (date +"%y-%m-$ChangeDate  %h :%m:%s ")"             flag=1             break        fi      fidoneif [  $Flag  -eq 1 ];then    while true     do    sleep 2s    echo  "date: $ (date + "%y-%m-%d %h:%m:%s") "    if [ $ (date +%h)  -eq $ aftertime ]; then        curdate=$ (date +%d)          changedate=$ (expr  $CurDate  + 1)          date -s  ' $ (date + "%y-%m-$ChangeDate  %h:%m:%s")          if [ $? -eq 0 ]; then             echo  "changed date: $ (date +"%y-%m-$ChangeDate  %h:%m:%s ")"              Flag=0             break        fi      fi   donefi
@echo  off@set startdate=05@set changedate=04@set changetime=18:59@set endtime=19:00@ echo  start Task: No. 05, 1 Change Time @set errnum=0:processdate@if %errnum% equ 1  (ping /n  5 127.0.0.1 > nul) @for  /f  "usebackq tokens=1,2,3 delims=-/ "  %%i in  (' date /t ')  do  (  set year=%%i  set mon=%% j  set todaydate=%%k  echo real_date: %%i-%%j-%%k  %todaydate%) @ if %todaydate% neq %startdate%  (  set errnum=1  goto : processdate ):P rocesstime@if %todaydate% equ %startdate%  (   for  /f  "usebackq tokens=1,2 delims=-/ "  %%a in  (' time /t ')  do  (      if  "%%a"  NEQ  "%changetime%"  goto :P rocesstime      if&nBSP; " %%a " == "%changetime% " call :ChangeCurDate   :P rocesstime_2 for / f  "usebackq tokens=1,2 delims=-/ "  %%a in  (' time /t ')  do  (        if  "%%a"  ==  "%endtime%"   (      echo %Year%-%Mon%-%TodayDate%         date  %year%-%mon%-%todaydate%         goto :eof        )  else  (         goto : processtime_2       )      )          ): changecurdateecho change_date: %year%-%mon%-%changedate% @date   %year%-%mon%-%changedate%  @goto  :eof

This article is from "Focus on Oracle Performance Tuning" blog, declined reprint!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.