Slow running scheduled tasks

I have a python script that runs once a day. It checks the database for certain criteria and sends a reminder email. Right now, it is in development so it only sends one email.

I added my own timestamps and logging and the script itself executes in less then a second. However, when run as a scheduled task on PA it usually takes > 30 seconds. Is this expected?

2021-09-18 04:00:48.312051 =====START=====
1 goals to process:

Goal ID: 1
Goal has daily reminder; will send new reminder for this goal.  Days difference=1.
Message sent!
EXECUTION TIME: 0 seconds.
2021-09-18 04:00:48.419765 =====END=====

2021-09-18 04:00:48 -- Completed task, took 30.69 seconds, return code was 0.

At certain times, it can take a while to kick off your script because lots of people are trying to start scripts at those times -- for example, a lot of people set up scripts to run on the hour, so that causes temporary congestion around that time. I see that your script was running at 4:00, so my guess is that that was what caused the slowdown there.

If you have some flexibility about the scheduling of the script, then picking an "odd" time should help -- say, 7 minutes past the hour.

Pls I'm fully in need. I want my script to be running every minute but from what I'm seeing, it seems the minimum interval is one day(24hrs). Please is there any way to use 1 minute interval. I thinking using schedule API but don't know if is a good practice considering CPU usage. Thanks

You may try the trick used or have a script that runs in a loop every minute -- but you must be aware that scheduled tasks running too long would be killed anyway. If you need a long/permanently running task, you need Always-on tasks feature.

Thanks. It looks like it is down to 7 seconds since I moved it to an uneven time.

You mention that a scheduled task running too long will be killed. What is considered "too long"?

It's 12 hours for paid accounts and 2 hours for free accounts.