1

I have created a script that checks if some other script is running

import os
import datetime
import time
from time import ctime

statinfo = os.stat('nemo_logs/nemo_log_file_' + time.strftime('%Y-%m-%d') + '.txt')
for i in range(1):
    first_size = statinfo.st_size
    time.sleep(10)
    if statinfo.st_size > first_size:
        print("SCRIPT IS RUNNING")
    else:
        print("SCRIPT IS NOT RUNNING. TRYING TO KILL THE SCRIPT...")
        os.system("pkill -9 -f selenium_nemo.py")
        print("SCRIPT KILLED. TRYING TO RESTART THE SCRIPT...")
        os.system("python selenium_nemo.py")
        print("SCRIPT STARTED")

If the script logs are increasing then we are OK, but if the script has stuck for some case i want to stop it and restart the script once more. First i kill the script and then i'am executing os.system("python selenium_nemo.py") . The script starts but it runs inside my main script. How i can i start the selenium_nemo.py on another proccess? 'The for loop is for later'

Thanks

2

1 Answer 1

2

You can use subprocess module for this. Check out this answer for more.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.