linux 中的更新时间和来自机器人框架的 solaris 机器

Update time in linux and solaris machines from robot framework

我已经获得了时间戳,并且在当前时间基础上增加了 1 小时。获得时间戳后,我需要更新在 linux 或 solaris 机器上的变量 ${convertDateTime} 中获得的时间。如果有人对此有任何想法,请告诉我?

*** Variables ***
${currentDateTime}       ${EMPTY}
${convertDateTime}       ${EMPTY}


*** Settings ***
Library                   DateTime

*** Test Cases ***
Test001 - Test to check whether set of mails can be backed-up and restored incrementally
        ${currentDateTime}=              Get Current Date       exclude_millis=True
        Log             ${currentDateTime}
        #${convertDateTime}=             Convert Date                     ${currentDateTime}    result_format= %Y%m%d:%H%M%S
        #Log            ${convertDateTime}
        ${date} =       Add Time To Date        ${currentDateTime}      01:02:00:000
        Log     ${date}
        ${convertDateTime}=              Convert Date                     ${date}       result_format= %m%d%H%M%Y%S
        Log             ${convertDateTime}

如果您希望将系统日期移动一小时。您可以使用下面的代码。

*** Settings ***
Library  OperatingSystem

*** Test Case ***

Run An Hour Faster

    ${stdout}=  run     date -Ins -s $(date -Ins -d '1 hour')
    Log To Console  ${stdout}

这应该可以。如果你想在远程机器上使用 SSHLibrary 并执行相同的命令!

希望对您有所帮助!