Published October 21, 2026
How to Monitor APScheduler Jobs
APScheduler runs inside your process. It is a thread, or the loop the process is blocked on. If that process exits, sleeps, or never calls start(), the job does not run. Nothing in the library sends mail about that. The log line only exists while someone is looking at the log.
A job that does start can still stay quiet. The built-in misfire window is 1 second. A new run is skipped while one copy is already running. A function that raises is caught and written to the log. The scheduler keeps going. The log is the record. It is not an alert.
The scheduling facts below are the APScheduler 3.x user guide, FAQ, and API. That is the current stable release. 4.0 is a pre-release with a different API. Its migration notes combine BlockingScheduler and BackgroundScheduler into one Scheduler, replace start() with run_until_stopped and start_in_background, use add_schedule for a repeating schedule, and number Sunday as 0. The examples on this page are 3.x. A separate beat process that publishes to a queue is Celery beat. A script with no scheduler is Node and Python. A Linux crontab on a machine you run is crontab not running. The five fields are in cron expression examples. The general pattern is how to monitor cron jobs.
The scheduler has to be started, and the process has to stay alive
The user guide picks the class from the environment.
BlockingSchedulerwhen the scheduler is the only thing in the process.start()does not return.BackgroundSchedulerwhen the scheduler should run in the background.start()returns immediately.AsyncIOSchedulerwhen the application uses asyncio.start()returns, and the event loop has to keep running.- Gevent, Tornado, Twisted, and Qt each have their own class. The same two rules apply: call
start(), and keep the process alive.
The FAQ's example of a job that never runs is a BackgroundScheduler, a call to start(), one cron job, and then the script ends. The process exits before the job is due. BlockingScheduler avoids that by blocking on start() after the jobs are added.
from apscheduler.schedulers.blocking import BlockingScheduler
scheduler = BlockingScheduler(timezone="UTC")
scheduler.add_job(nightly, "cron", hour=3, minute=0, id="nightly", replace_existing=True)
scheduler.start()
A web application usually wants BackgroundScheduler, or AsyncIOScheduler when the app is asyncio. FastAPI is asyncio, so that is AsyncIOScheduler, started once while the process stays up and shut down when the process is stopping. Flask and Django are the cases the FAQ names. It points at Flask-APScheduler and django_apscheduler and says those are third-party libraries the APScheduler developers are not responsible for. The FAQ's own instruction is to run the scheduler normally, after you have read the worker-process section.
That section says you cannot share one job store among worker processes. Sharing one produces duplicate execution or missed jobs, because APScheduler has no interprocess lock. The documented workaround is a scheduler in its own process. A server that starts the application in every worker, which the FAQ says is the usual production shape for uWSGI, starts a scheduler in every worker if start() is part of startup. Each of those schedulers runs the job. Gunicorn workers are the same shape. A reloader that starts the application a second time is a second scheduler if both processes call start(). replace_existing only replaces an id inside one job store. It does not coordinate two processes.
uWSGI disables the GIL, and with it the threads APScheduler needs, unless you pass --enable-threads. Without that switch, the jobs do not run.
The process also has to stay up between ticks. A dyno that sleeps, a container that exits, or a worker that is killed is the same outcome as that script: the scheduler is gone. Heroku Scheduler is a different scheduler, and that page is the one for a process the host is allowed to sleep. Render, Railway, and Fly.io restart and idle the same way. Cron in Docker is the container that exits. CronNudge does not see the process, and it cannot start it.
Triggers
CronTrigger has eight fields: year, month, day, week, day_of_week, hour, minute, and second. You can omit fields. Fields more significant than the smallest one you set default to *. Less significant fields default to their minimum, except week and day_of_week, which default to *. The minimum for second is 0. hour=3, minute=0 is 03:00:00 every day.
day_of_week is 0-6 or mon,tue,wed,thu,fri,sat,sun. The docs say the first weekday is always Monday. 0 and mon are Monday. 6 and sun are Sunday. Crontab uses 0 for Sunday. The names match the weekdays. The numbers do not.
CronTrigger.from_crontab() takes five fields: minute, hour, day of month, month, day of week. A string with any other count raises ValueError. It passes the fifth field through as day_of_week and does not convert it. The docs call that a historical mistake: APScheduler treats 0 as Monday, crontab treats 0 as Sunday, and 3.x will not change it. The 4.0 migration notes do change the numbers, so Sunday is 0 there. Names such as mon-fri mean the same days in both.
The trigger fires on the earliest time that satisfies every field. day and day_of_week both set means both have to match. On the five-field check, a restricted day-of-month and a restricted day-of-week run when either matches. Do not copy that pair onto the check until the cron tool lists the days you meant.
The day field also accepts 3rd fri, last fri, and last. Those are not five-field cron. week is the ISO week, and the check has no week field. Leave those off the check.
timezone on the trigger defaults to the scheduler's timezone. The scheduler's timezone defaults to the machine's local zone. The cron text does not contain the zone. Pass an IANA name, such as UTC or America/New_York. 3.11 accepts zoneinfo zones and deprecates pytz.
Daylight saving follows wall-clock time. The docs' example is hour=3, minute=30 in Europe/Helsinki: that job does not run at all on the last Sunday morning of March, and it runs twice on the last Sunday morning of October. The page says this is not a bug. Use a zone that does not observe daylight saving, such as UTC, or keep the schedule off the transition. The other schedulers are in cron jobs and daylight saving time.
IntervalTrigger takes weeks, days, hours, minutes, and seconds, each defaulting to 0. With no start_date, the first run is the current time plus the interval. A start_date in the past does not replay every missed interval. The trigger calculates the next time from now, using that start. The 4.0 migration notes change that trigger so the first run is immediate instead of waiting out the interval. DateTrigger runs once, at run_date. An empty run_date means the current time. A check is a repeating expectation. One success from a date trigger does not cover the next deadline.
jitter delays a cron or interval run by up to that many seconds. The check's grace has to cover the delay, or a healthy late run looks missed.
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.cron import CronTrigger
scheduler = BackgroundScheduler(timezone="UTC")
# 03:00:00 UTC every day. second defaults to 0.
scheduler.add_job(nightly, "cron", hour=3, minute=0, id="nightly", replace_existing=True)
# Monday through Friday, 09:00 in New York. mon-fri is 0-4, not crontab 1-5.
scheduler.add_job(
digest,
"cron",
day_of_week="mon-fri",
hour=9,
minute=0,
timezone="America/New_York",
id="digest",
replace_existing=True,
)
# Every 15 minutes, first run about 15 minutes after start().
scheduler.add_job(sync, "interval", minutes=15, id="sync", replace_existing=True)
# Once, at the current time. Pass run_date to choose another moment.
scheduler.add_job(once, "date", id="once", replace_existing=True)
# Five crontab fields. In 3.x the 0 here is Monday, not Sunday.
scheduler.add_job(
report,
CronTrigger.from_crontab("0 9 * * 0-4", timezone="UTC"),
id="report",
replace_existing=True,
)
scheduler.start() # returns immediately; the process has to stay alive
Missed runs, coalesce, and max_instances
A run is misfired when the scheduler could not start it at the scheduled time. The usual case in the user guide is a persistent job store and a scheduler that was down across that time. Each missed time is compared with misfire_grace_time, in seconds. The job may still run if it is inside that window. None means it may run no matter how late it is.
The scheduler's built-in job defaults are misfire_grace_time of 1 second, coalesce true, and max_instances of 1. add_job leaves those three as unset so the scheduler defaults apply. The user guide's configuration example sets coalesce to false and max_instances to 3 only when you want to change them.
With coalesce true, several due times become the latest one, and the user guide says no misfire event is sent for the times that were rolled in. With coalesce false, each due time is submitted, and each one outside the grace window is a miss. A miss is logged as Run time of job "..." was missed by ... and emitted as EVENT_JOB_MISSED. The function is not called for that time.
max_instances is how many copies of that job may run at once. The user guide says the default of one means a new run is treated as a misfire while the previous copy is still going. The scheduler logs Execution of job "..." skipped: maximum number of running instances reached (N) and emits EVENT_JOB_MAX_INSTANCES. The running copy is not stopped. That skip is not a lock you configure somewhere else. It is this counter. Two copies on purpose means raising max_instances, which is also how they pile up. The overlap page is prevent overlapping cron jobs. A run that starts and never returns is cron job stuck or hanging.
The default executor is a ThreadPoolExecutor named default with 10 workers. The user guide says a job that waits because the pool is full can be skipped as too late. Raise the pool, or raise misfire_grace_time, if that is the miss you are seeing. The 1-second default is shorter than a busy process.
The default job store is a MemoryJobStore named default. It keeps jobs in the process. A restart drops them. The usual pattern is to add the jobs again at startup, with a stable id. A persistent store keeps them across restarts. The user guide recommends SQLAlchemyJobStore on PostgreSQL when you are free to choose. It also says that adding jobs to a persistent store during startup requires an explicit id and replace_existing=True. Without that, each restart adds another copy of the job. add_job defaults replace_existing to false. The scheduled_job decorator always replaces, and its docs say the id has to be given for a persistent store. The scheduler does not enforce that requirement.
Job stores must not be shared between schedulers. That is the user guide, and it is the same rule as the FAQ's worker-process answer.
pause() on a job clears its next run time until resume(). scheduler.pause() stops processing. start(paused=True) starts without the first wakeup, so you can remove jobs before they run. A paused scheduler does not run the job, and it does not tell you.
A raised exception is logged, not alerted
The executor calls the function. An exception does not stop the scheduler. It is logged as Job "..." raised an exception and delivered as EVENT_JOB_ERROR, with the exception and the traceback on the event. A normal return is EVENT_JOB_EXECUTED. The user guide's listener checks event.exception to tell those two apart.
add_listener takes the callback and a mask. The callback receives the event. Omit the mask and it receives every event. Pass the constants you care about. EVENT_JOB_MISSED is the grace-window skip. EVENT_JOB_MAX_INSTANCES is the skip for too many running copies. Both happen without calling the function, so a try inside the function does not see them.
from apscheduler.events import EVENT_JOB_ERROR, EVENT_JOB_EXECUTED
def on_finished(event):
if event.exception:
print(event.traceback)
else:
print("ok")
scheduler.add_listener(on_finished, EVENT_JOB_EXECUTED | EVENT_JOB_ERROR)
The listener runs in the scheduler process. A process that has already exited does not call it. Debug logging on the apscheduler logger shows the decisions. It still does not page anyone.
What leaves no successful ping
- The process has exited, the dyno is asleep, or the container stopped.
start()was never called, or aBackgroundSchedulerwas left in a script that returned. - uWSGI is running the app without
--enable-threads. - The scheduler is paused, or the job is paused.
- The run was outside
misfire_grace_time. The default is 1 second. Withcoalescetrue, the earlier due times are not separate miss events. max_instanceswas already reached, so the new run was skipped. The default is 1.- The thread pool was full long enough that the run was skipped as late.
- The memory store lost the job on restart, and startup did not add it again.
- The function raised. The exception is in the log. Nothing sent
/fail. - The success ping is before the work, or the function caught the exception and returned.
CRONNUDGE_URLis unset, or the ping request failed. A failure there must not fail the job, so the check is what notices the gap.- The schedule can no longer fire:
end_datehas passed, aDateTriggeralready ran, or the fields never match. - Several workers each run the job. That case does ping, once per copy, so the check stays up. It is a duplicate run, not a missed one.
Ping after the work succeeds
The success URL is https://cronnudge.com/ping/YOUR_ID. GET, POST, and HEAD all count. A stored ping answers ok. YOUR_ID is the id in the ping URL. Anyone with that URL can send a ping, so keep it out of the image and out of the repo. Store it in the environment as CRONNUDGE_URL, with no query string and no /start or /fail on the end. The wrapper adds those.
urllib is enough. Five seconds is the timeout. A timeout or a connection error returns. It must not fail the job. A ping that never lands is what the check alerts on, after grace.
import os
import urllib.request
from urllib.error import URLError
def ping(path=""):
url = os.environ.get("CRONNUDGE_URL")
if not url:
return
try:
urllib.request.urlopen(url + path, timeout=5).read()
except (URLError, TimeoutError):
return
def nightly():
ping("/start") # optional; delete this line for a success ping only
try:
export()
except Exception:
ping("/fail")
raise
else:
ping()
urlopen sends GET. POST and HEAD count the same way. Re-raise after /fail. An exception you swallow is a normal return to APScheduler, and the log line Job "..." raised an exception never happens. /fail marks the check down immediately when it was not already down. A second /fail while it is already down does not send another alert. A later success is the recovery: one alert down, one when it comes back. A paused check stores the ping and does not alert.
?exit= is the other failure signal. ping("?exit=1") instead of ping("/fail"), not both on the same request. 0 is a success. 1 through 255 marks the check down when it was not already down. Anything else is ignored, and the ping stays a success.
An Idempotency-Key header is cut at 128 characters and matched per check. A repeat of the same key is a replay. It does not record a second ping and it does not send a second alert. A new run needs a new key.
The listener below is for the runs that never enter nightly. Register it before start(). It sends /fail for EVENT_JOB_MISSED and EVENT_JOB_MAX_INSTANCES. The first of those while the check is up is the down alert. It runs only while this process is alive. A dead process sends nothing. That silence is the missed success ping, and it is the alert after grace. One down alert. A later success is the recovery.
from apscheduler.events import EVENT_JOB_MAX_INSTANCES, EVENT_JOB_MISSED
def on_skip(event):
ping("/fail")
scheduler.add_listener(on_skip, EVENT_JOB_MISSED | EVENT_JOB_MAX_INSTANCES)
/start and a max runtime
/start records a start. It is not a success. While that start is still open, the deadline is the earlier of the schedule deadline and the start plus grace. The grace used for that run is at least 60 seconds. The alert is down, not stuck. Omit /start and the only clock is the schedule.
Turn on "Track start and finish," or set Max runtime (seconds), which turns run tracking on. A second /start while a run is open is then an overlap alert, and it does not close the first run. A success or /fail closes the open runs. Two success pings alone do not raise an overlap alert.
Max runtime is 1 second through 7 days. With a run open and a max runtime set, the deadline becomes that start plus the max runtime. It is not the earlier of that and the schedule. No finish means one stuck alert, once for that start, and the check goes down. A later success is the recovery. A job the scheduler never starts never calls /start, so it cannot go stuck. Silence until the schedule deadline is the alert. Free includes run tracking on 3 checks. Pro removes that cap. Details are in assertions, runs, and agents.
Set max runtime a little past the longest healthy run. The scheduler's max_instances of 1 skips the next tick while the first is still going, and that skip sends no /start. The alert you get is the missing success ping, or the stuck alert if the open run has a max runtime.
Match the check to the schedule
CronNudge stores five fields, minute first, or an interval in seconds. It has no year, no ISO week, and no seconds field. Sunday on the check is 0. Monday is 1. Friday is 5. Copy the timezone onto a cron check. An interval check stores UTC. The timezone field on the form is for cron.
The form's periods are 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 1 day, and 1 week. Grace is none, 1 minute, 5 minutes (the default), 15 minutes, or 1 hour. Anything else, from the plan minimum up to 31 days for an interval and from 0 through 7 days for grace, is an API value, and the API is on Pro. Creating a check sets the first deadline from that moment. A success then moves the deadline. An interval counts from the last success. A cron expression uses the next occurrence after that success, then adds grace. The cron tool lists the next runs before grace is added.
APScheduler 3.x day_of_week |
Weekday | Day of week on the check |
|---|---|---|
mon or 0 |
Monday | 1 |
tue or 1 |
Tuesday | 2 |
wed or 2 |
Wednesday | 3 |
thu or 3 |
Thursday | 4 |
fri or 4 |
Friday | 5 |
sat or 5 |
Saturday | 6 |
sun or 6 |
Sunday | 0 |
Every night at 03:00 UTC. hour=3, minute=0 and timezone="UTC". The omitted fields make that every day at 03:00:00. Check 0 3 * * *, timezone UTC. A success at 03:02 is inside the default 5 minutes of grace. The next deadline is 03:05 the next night. A night that never pings alerts at 03:05.
Weekdays at 09:00 in New York. day_of_week="mon-fri" (the same days as 0-4), hour=9, minute=0, timezone="America/New_York". Check 0 9 * * 1-5 in America/New_York. A success at 09:02 is inside the default grace. The next deadline is 09:05 on the next weekday. Saturday and Sunday are not expected. 0 9 * * 0-4 on the check is Sunday through Thursday. That is the string you would pass to from_crontab() to get Monday through Friday, and it is the wrong string for the check.
from_crontab("0 9 * * 1-5"). In 3.x the fifth field is not converted. 1 is Tuesday and 5 is Saturday. The job runs Tuesday through Saturday at 09:00. The check is 0 9 * * 2-6, in the same timezone you passed. Putting 0 9 * * 1-5 on the check would expect Monday through Friday, which is not what that trigger fires.
Every 15 minutes. IntervalTrigger with minutes=15. The check is an interval of 15 minutes. The gap is longer than Free's 5-minute minimum, so it is a Free check. The first APScheduler run is about 15 minutes after start() unless you set start_date. The check counts 15 minutes from the last success, plus grace, and it stores UTC. A cron trigger with minute="*/15" is a different schedule, */15 * * * *, on the clock at :00, :15, :30, and :45. That expression is also a Free check. Use the interval when the job is an IntervalTrigger, and the cron when the job is a cron trigger.
Every minute, or every 30 seconds. minutes=1, or a cron with minute="*", is * * * * *. It is valid cron, and it is not a Free check. Pro's minimum is 1 minute. seconds=30, or second="*/30", is under Free's 5-minute minimum and under Pro's 1-minute minimum. It cannot be a check at that cadence. CronNudge does not store a seconds field.
Free is 10 checks, a 5-minute minimum interval, email plus one Slack or Discord channel, and run tracking on 3 checks. Pro is $12 a month for 100 checks, a 1-minute minimum, signed webhooks, and the API. Details are on pricing.
FAQ
Why is an APScheduler job not running? The scheduler is inside the process. If the process has exited, start() was never called, or a BackgroundScheduler was created in a script that then ended, the job does not run. A paused scheduler or a paused job does not run. uWSGI without --enable-threads does not run the scheduler's threads. The built-in misfire_grace_time is 1 second, so a later run is skipped and logged. The built-in max_instances is 1, so a run that is still going causes the next one to be skipped. A memory job store drops its jobs on restart unless startup adds them again.
Why does the same job run twice under gunicorn? Each process that calls start() is its own scheduler. The FAQ says a job store cannot be shared across worker processes, and that sharing one causes duplicate execution or missed jobs, because there is no interprocess lock. Several workers, or a reloader that starts the application again, each run the job. The documented workaround is one scheduler in its own process. replace_existing only replaces an id in that process's store. A second success ping does not raise an overlap alert. A second /start does, once run tracking is on.
What do misfire_grace_time, coalesce, and max_instances do? misfire_grace_time is how many seconds after the scheduled time the job may still run. The built-in default is 1 second. None means it may run no matter how late it is. coalesce defaults to true, so several due times become one run, and the times that were rolled in do not emit a miss event. max_instances defaults to 1. When that many copies are already running, the scheduler skips the new one and logs that the maximum number of running instances was reached. That skip is EVENT_JOB_MAX_INSTANCES. A run outside the grace window is EVENT_JOB_MISSED.
How does an APScheduler weekday become a five-field check? CronNudge stores five fields, minute first, and Sunday is 0. APScheduler 3.x numbers Monday as 0 and Sunday as 6. mon-fri, or 0-4, at 09:00 is the check 0 9 * * 1-5. from_crontab() does not convert the weekday field, so 0 9 * * 1-5 passed to it runs Tuesday through Saturday, and the check for that is 0 9 * * 2-6. The timezone is separate. It defaults to the scheduler's zone, which defaults to the machine's local zone. Put that same name on a cron check. An interval of 15 minutes is a Free check. A schedule finer than Free's 5-minute minimum, or Pro's 1-minute minimum, cannot be a check at that cadence.
Does a job that raises alert me? Only if a ping is sent. The executor logs the exception and emits EVENT_JOB_ERROR. The scheduler keeps running. Send /fail, or ?exit= with a code from 1 to 255, and re-raise so the log line still happens. The first /fail while the check is up is one down alert. A second /fail while it is already down does not send another. A listener can send /fail for EVENT_JOB_MISSED and EVENT_JOB_MAX_INSTANCES, and that listener runs only while the process is alive. A dead process sends nothing. The missed success ping is the down alert after grace, and a later success is the recovery.
Can CronNudge see the job store or start the scheduler? No. It does not read the process, the logs, or the job store, and it cannot start the scheduler or run the job again. It only knows about pings it receives. The apscheduler log is where the exception and the skip warnings show up.
The scheduler only runs while the process does. The ping is how you hear about the run that never called home. Create the check, or read the five fields on the cron tool. Related: how to monitor cron jobs, crontab not running, cron expression examples, Celery beat, Node and Python, prevent overlapping cron jobs, and cron job stuck or hanging.