Forums

Scheduled task - Infinite loop

Hi, I'm trying to run a likely code as below using scheduled task:

from requests import get
from time import sleep
while True:
    re = get("https://example.com")
    if re.status_code == 200:
        print("code 200")
        sleep(30)
    else:
        print("another code")
        sleep(30)

But it would just log code 200, and then nothing after that. Anything could solve the problem? Also can i use PA scheduled task for purposes like that?

Thanks,

trnhai

That will hit the URL every 30 seconds and report the result. If that is what you want, then you do not need to change it.