我正在尝试创建一个与 RHN Satellite 的 API 接口的 python 脚本。下面的代码安排一个远程命令立即针对指定的服务器(var id)运行。问题是卫星服务器在我指定后正好 2 小时安排了命令。我找不到发生这种情况的地方。Satellite 服务器和客户端都是 RHEL6。这是我的代码:
#!/bin/python
import xmlrpclib
from datetime import date, datetime, time, timedelta
from sys import argv
import socket
import os
SATELLITE_URL = "https://URL"
SATELLITE_LOGIN = "username"
SATELLITE_PASSWORD = "password"
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
id = [] #Satellite server ID
script = "#!/bin/sh \n yum update -y"
def schedule_script():
earliest_occurrence = xmlrpclib.DateTime()
print earliest_occurrence
client.system.scheduleScriptRun(key, id, "root", "root", 300, script, earliest_occurrence)
schedule_script()
client.auth.logout(key)
当我打印变量“earliest_occurrence”时,它会打印当前时间。当我在卫星服务器上执行“日期”时,它会打印正确的时间。
任何帮助将不胜感激。谢谢!