Use your operating system’s scheduler for a Python script that should start, run, and exit once a day: Task Scheduler on Windows, cron on Linux, or launchd on macOS. Configure the job to call the exact Python interpreter and script by absolute path, choose the intended local time, and capture output so you can diagnose failures. You do not need to keep a Python process running for these approaches.
Choose a scheduler that fits your machine and timing
First decide what “daily” means for your job: a run at a local clock time, such as 6:30 a.m., or a run at an elapsed interval. The instructions below schedule a daily calendar-time run. They assume the computer is powered on and the scheduler is available at the configured time; do not assume every scheduler catches up missed runs in the same way.
| Platform | Scheduler | How you define the schedule | What needs to stay running | Where to investigate failures |
|---|---|---|---|---|
| Windows | Task Scheduler | A daily trigger at a chosen time | The scheduled task is managed by Windows; your script runs when triggered. | Task status, History, and the Task Scheduler Operational event log. |
| Linux | cron | Five time/date fields in a crontab line | cron must be available and running; your script itself need not stay open after completion. | Your redirected log file and the system’s cron logs, whose location depends on the distribution. |
| macOS | launchd | A property-list job with a calendar interval | launchd manages the job; the script runs when the configured interval is reached. | Configured standard-output and standard-error files, plus system job diagnostics. |
For Windows, Microsoft describes Task Scheduler as a way to automate routine tasks on a chosen computer. Its documentation covers daily triggers and troubleshooting: Task Scheduler and troubleshooting scheduled tasks. For cron behavior and syntax, consult the manual for the implementation installed on your Linux system; the cited Linux manual is crontab(5). Apple’s job-configuration reference is an archived launchd guide; use current macOS documentation for current loading and management commands.
Prepare a reliable command before scheduling it
A scheduled process usually starts with a different working directory, environment, and account than an interactive terminal session. Use absolute paths and run the intended command manually before creating the job.
#1 Best Overall
- Find the project and script paths. For example, identify the full path to
script.pyand any input or output files it uses. - Find the intended Python interpreter. If the project uses a virtual environment, use its interpreter directly. A virtual environment has its own Python packages; activation is not required when you call that interpreter by full path. See Python’s venv documentation.
- Run the exact command from a terminal. Use the same interpreter and arguments that the scheduler will use. Check that it exits successfully and can read or write required files.
- Set the working directory and account deliberately. Use the account with the needed permissions and make the project directory explicit in the scheduler where supported.
- Choose a durable log location. Ensure the account running the task can write to it. Record standard output and errors, or use the scheduler’s history and logs.
For a Windows virtual environment, the command shape is C:pathtoproject.venvScriptspython.exe C:pathtoprojectscript.py. For a typical Linux or macOS virtual environment, it is /path/to/project/.venv/bin/python /path/to/project/script.py. Replace all example paths with real paths on your machine.
Windows: create a daily task in Task Scheduler
- Open Task Scheduler and select Create Basic Task (or the full task-creation option if you need additional settings).
- Give the task a descriptive name, such as Daily Python report, and proceed to the trigger settings.
- Choose a Daily trigger, set the start date and the local time you want, then continue.
- Choose the action to start a program. For Program/script, enter the full path to the Python executable, such as
C:pathtoproject.venvScriptspython.exe. - In Add arguments, enter the full path to the script, for example
C:pathtoprojectscript.py. Add the script’s command-line arguments here if it requires them. - Set the task’s Start in or working-directory field, where available, to the project directory. Review the account and run conditions in the task’s properties; use an account that can access the project files and any required resources.
- Save the task, then use Task Scheduler to run it on demand. Confirm the expected output and inspect task status or History after the test.
Do not put the script path in the executable field: the executable is Python, and the script is its argument. If paths include spaces, enter them in the appropriate fields and test the resulting task rather than assuming quoting is correct.
Linux: schedule a daily run with cron
A user crontab entry begins with five fields for minute, hour, day of month, month, and day of week, followed by the command. To run at 06:30 every day, an illustrative entry is:
Rank #2
30 6 * * * /path/to/project/.venv/bin/python /path/to/project/script.py >> /path/to/project/script.log 2>&1
The redirection appends both standard output and standard error to the log file. The example is for a user crontab and runs as the user whose crontab contains the line. Edit that user’s crontab using the command provided by the installed cron implementation, add the entry, save, and verify the saved crontab with its listing command. Cron implementations and distributions vary, so use the local manual for details beyond this conventional line.
Free tools Windows power users keep installed
One-click scans. No signup required.
- Use absolute paths for the interpreter, script, and log. Cron runs the command through a shell, so shell syntax and quoting affect the result.
- Ensure the log directory exists and the crontab’s user can write to it.
- Do not assume cron inherits variables from your terminal profile. Set any required environment values in the crontab or in a wrapper script, with secrets handled appropriately.
- Confirm the machine’s timezone and cron implementation if the job must run at a precise local time.
In the cited Linux cron manual, a scheduled local time that does not exist during a daylight-saving transition does not match; a repeated local time may match twice. That behavior is important for jobs where duplicate or missed execution has consequences. See the crontab manual for the relevant implementation and details.
macOS: use launchd for calendar scheduling
launchd jobs are configured with property lists. Apple’s archived developer guide documents a job configuration using ProgramArguments for the executable and its arguments, StartCalendarInterval for calendar-based scheduling, and StandardOutPath and StandardErrorPath for output and errors.
- Create a property-list job configuration appropriate to whether it should run for your user or as a system service. The location and loading procedure depend on the job type and current macOS version.
- Set
ProgramArgumentsas an array: the first item should be the absolute path to the virtual environment’s Python interpreter, followed by the script path and any arguments. - Set
StartCalendarIntervalto the desired calendar time, and configure output and error paths that the job’s account can write. - Use current macOS-specific instructions to load, inspect, and test the job. Check the configured log files after a run.
The Apple reference is archived, so this describes the configuration pattern rather than prescribing current command-line management steps. Do not copy an old loading command into a current macOS setup without checking current Apple guidance: Creating Launch Daemons and Agents.
Keep the Python environment and scheduled context consistent
Many “works in my terminal” failures come from using a different Python installation or context under the scheduler. A virtual environment’s interpreter uses that environment’s installed packages even if the environment is not activated in a shell. Prefer its full interpreter path over relying on whichever python happens to be on the scheduler’s PATH.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →- Dependencies: install required packages in the environment whose interpreter the task invokes.
- Relative paths: convert file references to absolute paths or set the working directory explicitly.
- Environment variables: define needed configuration for the scheduled process; do not assume interactive-shell settings are present.
- Permissions: test access to input files, output directories, network shares, and credentials under the task’s execution account.
- Interactive prompts: scheduled jobs generally need to run unattended. Supply required arguments or configuration and remove any wait-for-input behavior.
Troubleshoot a job that does not run as expected
- Run the exact command manually. Use the same interpreter, script path, arguments, and working directory intended for the scheduled task. Fix Python errors before debugging the scheduler.
- Check the interpreter and script paths. Confirm both exist and that the task account can execute or read them. Do not rely on a PATH entry that only exists in your terminal.
- Check the working directory and files. A relative path may resolve differently when launched by a scheduler. Use absolute paths and confirm permissions for inputs, outputs, and logs.
- Inspect the scheduler’s evidence. On Windows, review task status and History; Microsoft also points to the Task Scheduler Operational event log. On Linux, inspect the redirected log and the distribution’s cron logs. On macOS, inspect the standard output and error paths configured for the job.
- Check whether the script is still running. A task that starts but never finishes may be waiting for input, blocked on a network call, or otherwise hanging. Inspect the running process and the script’s own behavior; Microsoft’s troubleshooting guidance includes checking task status and processes that remain running.
- Revisit time and timezone assumptions. Confirm the host’s local time and timezone. If your job is sensitive to daylight-saving transitions, account for the cron behavior described above and verify the appropriate behavior for your chosen scheduler.
When a job runs at the right time but does the wrong thing, compare the scheduled account, interpreter, environment, working directory, and arguments with the manual test. Change one variable at a time and retain logs until the run is understood.
When an in-process Python scheduler makes sense
A Python library such as schedule can be useful when an application is already designed to stay running and own its timing. Its documented pattern registers a daily job and repeatedly checks for due work:
import schedule
import time
def job():
print("Run the daily task")
schedule.every().day.at("10:30").do(job)
while True:
schedule.run_pending()
time.sleep(1)
This loop is a long-running process, unlike an OS task that starts a script for a run and exits. If the process stops or the machine reboots, the loop stops; the package documentation says it is not intended for persistence across restarts or exact timing requirements. Use an OS scheduler when the goal is to launch a standalone script daily, and use an in-process scheduler only when the application’s continuous process is itself part of the design. The documentation page identifies versions tested through Python 3.11, so check compatibility for the Python version you deploy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your daily Python task is taking website screenshots, you can call ScreenshotNeo instead of setting up browser automation and browser drivers. Its API returns a screenshot or PDF from one GET request; before capture it accepts consent banners and removes supported cookie banners, newsletter popups, and chat widgets, and it does not bill bot checks, blank pages, failed loads, timeouts, or cache hits. Its response includes page-verdict and billing headers.
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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallHere is a Python request you can place in a daily script. Install the requests package in the interpreter environment used by your scheduler, replace the key, and change the target URL as needed:
Best Value
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
See the ScreenshotNeo API documentation for request options and response details. ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Learn more at ScreenshotNeo.
Sign up free for 1,000 screenshots a month with no card.
Frequently Asked Questions
Does my computer have to be on for the daily run?
Yes. The scheduler needs the computer to be available when the job is due; behavior after a missed run depends on the scheduler and configuration.
Can I schedule a script that uses a virtual environment without activating it?
Yes. Configure the task to call the environment’s Python executable by its full path.
Should I use an OS scheduler or the Python schedule package?
Use an OS scheduler for a standalone script that should start and exit daily. The package is for an application process that is already intended to remain running.
Quick Recap
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.

