Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11To find why a Python cron job failed, capture the exception inside its except block, make sure the log record passes the configured logger and handler levels, and send it to a destination that your deployment retains. Include a safe job or run identifier so the traceback can be tied to the execution. If you also need to detect jobs that never started or did not finish, add a scheduled-job check-in signal: exception logging alone cannot reveal a run that produced no exception record.
What a traceback can—and cannot—tell you
A traceback records exception details and the frames unwound as Python searched for a handler. It can show where an error occurred, but it may not identify which scheduled execution or request was affected unless your application records that context too.
As an Amazon Associate I earn from qualifying purchases.
Python’s standard logging API provides a shared event-recording mechanism that application code and third-party modules can use together. Logging is a means of tracking events that happen when software runs, as the Python Software Foundation puts it in its Logging HOWTO. A log record only helps with reconstruction if it is emitted, reaches a configured destination, and remains available long enough to inspect.
Make sure the logging path reaches a retained destination
Use a named logger in the module that runs the job, then configure logging deliberately for the application or deployment. A logger creates records; handlers route accepted records to destinations such as standard error or a file. A configured destination is not automatically a retained destination: retention depends on what the process supervisor, container platform, operating system, or logging system does with it.
#1 Best Overall
Both logger and handler thresholds can filter records. For example, an ERROR record can still disappear from the destination if the relevant logger or handler is configured above ERROR. Check the effective configuration and the actual output path rather than assuming that calling a logging method guarantees a saved record. Python’s Logging HOWTO explains logger levels, handlers, and destinations.
Capture the exception where it is handled
Call logger.exception() inside the except block that handles the error. It logs at ERROR and adds exception information, including the traceback. Use a short operation label and safe identifiers—such as a job name, run ID, or request/correlation ID—when your application has them.
Rank #2
import logging
logger = logging.getLogger(__name__)
def run_job(run_id):
try:
perform_job_work()
except Exception:
logger.exception("Scheduled job failed", extra={"run_id": run_id})
raise
This example illustrates the standard-library call and a contextual identifier; your formatter and logging pipeline must be configured to include extra fields if you want them rendered in the output. Re-raising preserves failure behavior for the caller or scheduler. If your job intentionally handles the error and continues instead, make that choice explicit in the application’s control flow.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Python also permits passing exception information explicitly with exc_info to a suitable logging call. The standard API reference recommends Logger.exception() for the common case and says to use it only from an exception handler. See the Python logging API reference.
Do not confuse exception traceback with the current stack
Exception information and stack_info=True capture different evidence. Exception information describes the exception and traceback associated with it. Stack information describes the current thread’s call path up to the logging call, whether or not an exception was raised. The former shows frames unwound while Python looked for an exception handler; the latter shows the path leading to the point where the log was written. Use the evidence that answers the diagnostic question instead of treating the two as interchangeable.
Add a job lifecycle signal to find missed or timed-out runs
Exception logs describe failures that reached an exception handler. They do not prove that a scheduled execution started, and they cannot by themselves distinguish a missed schedule from a process that started but stopped reporting. A cron monitor adds a separate lifecycle signal through check-ins.
Sentry’s Cron Monitor documentation describes three check-in states:
| State | Meaning |
|---|---|
in_progress |
The scheduled execution has started. |
ok |
The execution completed successfully. |
error |
The execution completed with an error. |
A monitor can flag a missing check-in within the expected window as missed, or an execution that remains in progress beyond its configured maximum runtime as timed out. The Sentry Python documentation provides instrumentation patterns using a decorator, a context manager, or a manual check-in. Choose a pattern that fits how the job is invoked, and ensure the completion state is sent on both success and failure paths. The Sentry help article on cron monitors marked as timed out specifically advises verifying that the initial in-progress check-in and final successful check-in are both sent.
Best Value
These check-ins complement rather than replace exception logging: a lifecycle signal tells you whether the run started and reached a terminal state; the exception record provides failure details when an exception was handled and logged.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Decide whether logs stay local or go to a monitoring service
Standard logging is an API and routing mechanism. You can direct records to destinations that you operate and retain. A hosted error-monitoring service is a separate collection layer that can centralize exception events and contextual data for search and alerting. The choice depends on who will operate storage and search, what context should be collected, and whether the deployment needs a centralized view across jobs or services.
Sentry’s Python SDK reference documents APIs including capture_exception, set_context, and set_extra, along with release, environment, and data-collection configuration. The reference surfaced as SDK version 2.71.0; check the documentation matching the SDK version actually deployed because APIs and configuration can change. Sending events to an external service also means reviewing its data collection settings: avoid placing credentials, personal data, or other sensitive values in exception messages or context unless their collection is necessary and permitted. No particular deployment’s privacy settings are established by the SDK API alone.
Quick Recap
Use this diagnostic sequence when a run fails
- Find the execution. Record a job name and run identifier, plus a request or correlation identifier when relevant and available.
- Log at the handling point. Use
logger.exception()inside the exception handler for the traceback-bearing record. - Check filtering. Confirm the effective logger level and each relevant handler level allow the ERROR record through.
- Verify the destination. Identify whether records go to stderr, a file, or another configured destination, then confirm the deployment retains and exposes that output.
- Check lifecycle reporting. Where missed runs or stuck executions matter, confirm the monitor receives its start check-in and an appropriate terminal check-in.
- Assign alert ownership. Decide who receives and investigates log or monitor alerts; an emitted signal without an owner does not ensure a failure is addressed.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




