Home › Cron Job on Windows
Cron Job on Windows
Windows has no native cron daemon. This guide covers the three real options: Task Scheduler (built-in), WSL crontab (real cron syntax), and third-party cron software - with the trade-offs of each.
Windows Cron Equivalent: Task Scheduler
Task Scheduler is the native Windows tool for running scripts and programs on a schedule. It covers everything cron does and more - GUI-based, supports triggers based on time, events, startup and user login. The main difference: no cron expression syntax. Schedules are configured through a dialog instead. Official reference: Task Scheduler documentation on Microsoft Learn.
Create a Scheduled Task via GUI
1. Open Task Scheduler
Press Win + R, type taskschd.msc and press Enter.
Or search "Task Scheduler" in the Start menu.
Works on Windows 10, Windows 11 and Windows Server.
2. Create Basic Task
Click "Create Basic Task" in the right panel. Give it a name, set the trigger (daily, weekly, on startup...) and point it to your script or program.
3. Run whether logged on or not
In the task properties, under General, select "Run whether user is logged on or not". Otherwise the task only runs when your user is active. This is the most commonly missed setting for server tasks.
4. Set the working directory
In the "Action" step, the "Start in" field sets the working directory. Without it, relative paths in your script will fail - same as the cron PATH problem on Linux.
Create a Task via PowerShell or Command Line
For automation and scripting, schtasks and PowerShell are more practical than the GUI - and the only way to script task creation from a deployment pipeline:
# Run a Python script daily at 2 AM $action = New-ScheduledTaskAction -Execute "python.exe" -Argument "C:\scripts\backup.py" $trigger = New-ScheduledTaskTrigger -Daily -At "02:00" Register-ScheduledTask -TaskName "DailyBackup" -Action $action -Trigger $trigger -RunLevel Highest
# Using schtasks (command line / cmd.exe) schtasks /create /tn "DailyBackup" /tr "python C:\scripts\backup.py" /sc daily /st 02:00 /ru SYSTEM # Run a task immediately, on demand schtasks /run /tn "DailyBackup" # List all scheduled tasks schtasks /query /fo list
Real Crontab on Windows with WSL
If you want actual cron syntax on Windows, WSL (Windows Subsystem for Linux) gives you a full Linux environment, including a real crontab. This is the option developers reach for - same syntax you already know, same crontab files you can copy to a Linux server later.
# Enable WSL (PowerShell as Administrator) wsl --install # Inside WSL, install and start cron: sudo apt update sudo apt install cron sudo service cron start # Edit the WSL crontab exactly like on Linux: crontab -e
A typical WSL crontab entry looks identical to a Linux one - the syntax does not change:
0 2 * * * /usr/bin/python3 /home/user/backup.py >> /home/user/backup.log 2>&1
WSL crontab does not start automatically on Windows boot
This is the single biggest gotcha with WSL cron. WSL does not run in the background by default - the cron daemon stops the moment the WSL session ends, which happens when you close your last WSL terminal window. Three ways to work around it:
- Keep a WSL terminal open - simplest, but fragile on a server that reboots or where you log out.
- Launch via Windows Task Scheduler on startup - create a scheduled task that runs
wsl sudo service cron startat system boot. - Use a WSL systemd distro - newer WSL versions support systemd (
/etc/wsl.confwithboot.systemd=true), which keeps cron running more reliably across sessions.
For anything running unattended on a server, plain Task Scheduler is usually more reliable than WSL cron - WSL is best suited to development environments where you control when the machine is on.
Third-Party Cron Software for Windows
If neither Task Scheduler nor WSL fits, there is a small category of dedicated cron-syntax schedulers built for Windows:
NSSM
Non-Sucking Service Manager wraps any script or executable as a Windows Service. Good for scripts that need to run continuously or on a tight interval without Task Scheduler's overhead.
cronw / similar wrappers
Small open-source tools that parse real cron expressions and run as a Windows background process, giving you cron syntax without WSL. Useful if your team already has crontab files to reuse as-is.
Commercial job schedulers
Enterprise tools (e.g. job scheduling suites used in regulated industries) offer cron-like scheduling plus retries, alerting and dependency chains - overkill for a single script, useful at scale.
Which Option to Use
| Feature | Task Scheduler | WSL crontab | 3rd-party software |
|---|---|---|---|
| Built-in, no install | Yes | No (needs WSL) | No |
| Real cron syntax | No | Yes | Sometimes |
| Survives reboot unattended | Yes | Needs extra setup | Usually yes |
| Best for | Production servers | Dev environments | Cross-platform teams |
Linux vs Windows Scheduling Comparison
| Feature | Linux cron | Windows Task Scheduler |
|---|---|---|
| Minimum interval | 1 minute | 1 minute (or on trigger events) |
| Syntax | Cron expressions | GUI / XML / PowerShell |
| Run as different user | Yes (crontab -u) | Yes (run as SYSTEM or specific user) |
| Run on startup | @reboot | Startup trigger |
| Logging | Redirect to file | Task history in Event Viewer |
| Environment variables | Minimal (set explicitly) | Inherits from user or SYSTEM |
Using WSL or need a cron expression for another platform?
Our generator works for Linux, AWS, Kubernetes and more. If you are using WSL, it is standard Linux cron syntax.