Uncategorized

taskmanager – Return updated datetime and script name as a dataframe – python


The overarching aim of my query is to monitor the functioning of scripts through TaskManager. I have numerous scripts that are being run as recurring time points. But I have no idea if the script is being executed or hasn’t run for whatever reason.

I’m setting out to create a central monitoring file for all my scripts that will return the datetime and if it ran. More importantly, if it didn’t execute.

For this question, I’ve got a test or dummy script will run for a period of 5 minutes and then it will be terminated.

I’ll setup TaskManager to run this script every minute. I want to create a central df that appends the datetime, along with the name of the script. That way, on the 6th minute when TaskManager runs, the script will not execute, which should be recorded as a null value.

import multiprocessing
import time
import pandas as pd
import datetime

# foo function
def foo(n):
    for i in range(10000 * n):

        test = pd.DataFrame(columns=['Script', 'DateTime', 'Processing'])

        test["DateTime"] = datetime.datetime.now()

        print(test)

        time.sleep(1)

        #return test

if __name__ == '__main__':

    p = multiprocessing.Process(target=foo, name="Foo", args=(10,))
    p.start()

    time.sleep(300)

    p.terminate()

    p.join()



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *