How to set up cron jobs on a Windows VPS (Task Scheduler)
What this is
Windows' cron is Task Scheduler: it runs scripts and programs on a schedule (or at events like startup), and it's the right home for the recurring work on your VPS, backup scripts, cleanups, report jobs. This is the setup that keeps working, most "my scheduled task doesn't run" stories trace to two checkboxes covered below.
Creating a job (the GUI way)
Run taskschd.msc → Create Task (not "Basic Task", the full dialog is worth it):
- General tab: name it, select Run whether user is logged on or not (the checkbox, without it the job only runs while you're RDP'd in, which on a server means never), and Run with highest privileges if the script needs admin.
- Triggers tab: New → Daily at 03:30, or On a schedule of your choice, or At startup (the other classic need). Add a random delay if several jobs share a time.
- Actions tab: Start a program. For a PowerShell script, the program is
powershell.exe(orpwsh.exe) with arguments:
-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\backup.ps1"
and set Start in to the script's folder, relative paths inside scripts fail without it, the same trap as cron's working directory.
- OK, enter the account password when prompted (that's what lets it run unattended).
The command-line ways
One-liner with the classic tool:
schtasks /Create /TN "NightlyBackup" /TR "powershell -NoProfile -ExecutionPolicy Bypass -File C:\Scripts\backup.ps1" /SC DAILY /ST 03:30 /RU Administrator /RP
Or PowerShell-native, script-friendly:
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Scripts\backup.ps1"
$trigger = New-ScheduledTaskTrigger -Daily -At 3:30am
Register-ScheduledTask -TaskName "NightlyBackup" -Action $action -Trigger $trigger -User "Administrator" -Password "yourpassword" -RunLevel Highest
(An AI chatbot converts any crontab line you're used to into either form on request.)
Translating crontab thinking
| Crontab habit | Task Scheduler equivalent |
|---|---|
30 3 * * * |
Daily trigger, 03:30 |
*/5 * * * * |
Daily trigger + "Repeat task every 5 minutes for a duration of 1 day" |
@reboot |
Trigger: At startup (or make it a real service) |
flock (no overlaps) |
Settings tab → "Do not start a new instance" (the default) |
MAILTO |
Capture output to a log (below), Task Scheduler doesn't email |
Make failures noisy (the cron lesson applies here too)
Task Scheduler records Last Run Result (0x0 = success) and a History tab, but nobody looks until it's been broken for a month, same story as cron. So capture output in the script itself:
Start-Transcript -Path "C:\Scripts\logs\backup.log" -Append
# ... the actual work ...
Stop-Transcript
and for jobs that matter (backups!), end the script with a dead-man's-switch ping so you're alerted when it stops running, not just when it errors.
When the task "doesn't run"
The checklist, in order of likelihood: "Run whether user is logged on or not" wasn't set (it ran only during your RDP sessions), the account password changed since the task was registered (re-enter it in task properties), Start in is empty and the script needed its folder, or execution policy blocked the script (the -ExecutionPolicy Bypass argument sidesteps that per-task). The History tab plus your transcript log names which.
Still need help?
You can open a support ticket. So we can help on the first reply, it's worth mentioning:
- the VPS hostname or IP,
- the task's trigger and action (a screenshot of its properties helps),
- the Last Run Result code and anything in the History tab.
Related questions
- "How do I run a script on a schedule on Windows Server?"
- "What is the Windows equivalent of cron?"
- "Why does my scheduled task only run when I'm logged in?"
- "How do I run a task every 5 minutes on Windows?"
- "How do I log a scheduled task's output?"