简体   繁体   English

是否有python的预定任务对象

[英]Is there a scheduled task object for python

I have multiple python scripts that run overnight, via the Scheduled Task. 我有一个在夜间运行多个Python脚本,通过计划任务。 What I want to do is a run another python script that runs after these scripts that gets information about that particular task and gives me information about the script time, script name, whether it ran successfully etc. 我想要做的是运行另一个Python脚本,该脚本在这些脚本之后运行,以获取有关特定任务的信息,并为我提供有关脚本时间,脚本名称,是否成功运行等信息。

Using python how do i get access to these properties? 使用python我如何访问这些属性? What object is can I use for this? 我可以为此使用什么对象?

Thanks 谢谢

you can write your own logmanager class! 您可以编写自己的logmanager类! when you run your script for each thing that was executed, you can write in a log file. 当为已执行的每件事运行脚本时,可以写入日志文件。
For example write an LogManager: 例如编写一个LogManager:

class LogManager():
    def get_time():
        # via time,date lib

    def get_script_name():
        # via os, path, system libs

    def get_pid():
        # via os, system libs

    def append_all_information_in_file():
        log = open("logfile", "a")
        log.write(get_time(), get_script_name(), get_pid())
        log.close()

And if you run your scripts, you can inherit the from the LogManager class that exactly Logs Information what you want. 而且,如果您运行脚本,则可以从LogManager类继承该类,该类恰好将所需信息记录在日志中。 I hope I have understood your question correctly and the answer was helpful! 希望我已经正确理解了您的问题,答案对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM