Programming guide

Schedule a script to run automatically

Set a Python or shell script to run on a regular schedule using Windows Task Scheduler or cron, with logging so you can tell whether each run actually worked.

Estimated time: 45–90 minutesUpdated: 1 October 2026

Use this guide when you have a script that already works when you run it by hand, such as a backup, report or data download, and you want it to run daily or weekly on its own. Have the full path to the script and to the Python interpreter or shell you use ready.

Step by step

  1. Make the script safe to run unattended

    Change every file path in the script to an absolute path, because scheduled tasks often start in a different working folder from the one you use. Make the script write a line to a log file at the start and end of each run, including the date and time, and log any error message before exiting. Run it once by hand from a different folder to prove it no longer depends on where you start it.

Members

The rest of this guide is for members

The rest of this guide – the remaining steps, a ready-to-use checklist, practical tips and fixes for common problems – is for members. Membership unlocks every ABCDayZ guide.

£3.99 for 1 month or £29 for 12 months. One payment, no automatic renewal.

Unlock all guides

Already a member on another device? Open your personal access link. Bought Programming with AI? Your first month is included.