We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
经过一个周的观察,发现wskey经常在转换完成的24h零20min失效,而corn表达式不支持间隔24 h以上执行脚本 故建议添加脚本check_script.py如下,从而使得wskey转换不用频繁操作
import os import time # 上次执行的时间文件 LAST_RUN_FILE = "/ql/data/scripts/shufflewzc_faker3_main/last_run_time.txt" SCRIPT_TO_RUN = "/ql/data/scripts/shufflewzc_faker3_main/jd_wskey.py" LOG_FILE = "/ql/data/scripts/shufflewzc_faker3_main/execution.log" # 当前时间戳 current_time = int(time.time()) # 初始化上次执行时间 last_run_time = 0 # 检查是否存在上次执行时间文件 if os.path.isfile(LAST_RUN_FILE): with open(LAST_RUN_FILE, 'r') as file: content = file.read().strip() # 检查内容是否为空 if content: try: last_run_time = int(content) except ValueError: print("上次执行时间无效,重置为 0。") last_run_time = 0 else: print("上次执行时间文件为空,重置为 0。") last_run_time = 0 else: print("上次执行时间文件不存在,重置为 0。") # 计算时间差 time_diff = current_time - last_run_time # 25 小时的秒数 twenty_five_hours = 25 * 60 * 60 # 检查时间差是否大于等于 25 小时 if time_diff >= twenty_five_hours: # 执行你的任务 try: os.system(f"python {SCRIPT_TO_RUN}") # 更新上次执行时间 with open(LAST_RUN_FILE, 'w') as file: file.write(str(current_time)) # 记录执行时间 with open(LOG_FILE, 'a') as log_file: log_file.write(f"脚本在 {time.ctime(current_time)} 执行\n") except Exception as e: print(f"错误:脚本执行失败。{e}") else: print("脚本最近已执行,未采取任何行动。")
The text was updated successfully, but these errors were encountered:
你可以修改定时规则,让它在23点,1点执行
Sorry, something went wrong.
No branches or pull requests
经过一个周的观察,发现wskey经常在转换完成的24h零20min失效,而corn表达式不支持间隔24
h以上执行脚本
故建议添加脚本check_script.py如下,从而使得wskey转换不用频繁操作
import os import time # 上次执行的时间文件 LAST_RUN_FILE = "/ql/data/scripts/shufflewzc_faker3_main/last_run_time.txt" SCRIPT_TO_RUN = "/ql/data/scripts/shufflewzc_faker3_main/jd_wskey.py" LOG_FILE = "/ql/data/scripts/shufflewzc_faker3_main/execution.log" # 当前时间戳 current_time = int(time.time()) # 初始化上次执行时间 last_run_time = 0 # 检查是否存在上次执行时间文件 if os.path.isfile(LAST_RUN_FILE): with open(LAST_RUN_FILE, 'r') as file: content = file.read().strip() # 检查内容是否为空 if content: try: last_run_time = int(content) except ValueError: print("上次执行时间无效,重置为 0。") last_run_time = 0 else: print("上次执行时间文件为空,重置为 0。") last_run_time = 0 else: print("上次执行时间文件不存在,重置为 0。") # 计算时间差 time_diff = current_time - last_run_time # 25 小时的秒数 twenty_five_hours = 25 * 60 * 60 # 检查时间差是否大于等于 25 小时 if time_diff >= twenty_five_hours: # 执行你的任务 try: os.system(f"python {SCRIPT_TO_RUN}") # 更新上次执行时间 with open(LAST_RUN_FILE, 'w') as file: file.write(str(current_time)) # 记录执行时间 with open(LOG_FILE, 'a') as log_file: log_file.write(f"脚本在 {time.ctime(current_time)} 执行\n") except Exception as e: print(f"错误:脚本执行失败。{e}") else: print("脚本最近已执行,未采取任何行动。")
The text was updated successfully, but these errors were encountered: