crontab for windows
Project description
crontab-win
A simple cron-like task scheduler for Windows.
This tool allows you to schedule tasks using a crontab.txt file, similar to how cron works on Unix-like systems.
For background on the project read this blogpost about it
Installation
Install this tool using pip:
pip install crontab-win
Usage
This package provides two commands: crontab and ctab. Both can be used interchangeably.
Running the Scheduler
To start the scheduler, simply run:
crontab
or
ctab
This will start the scheduler in the foreground. It will read your crontab file and execute tasks as per the schedule. You should keep this window minimized.
By default, the scheduler looks for a file named crontab.txt in your user's home directory (e.g., C:\Users\YourUser\crontab.txt).
You can specify a different crontab file using the -c or --crontab-file option:
crontab -c "C:\path\to\my\custom_crontab.txt"
Editing the Crontab File
To open your crontab file for editing, use the show command:
crontab show
or
ctab show
This will open crontab.txt in your default text editor. If the file doesn't exist, it will be created with a helpful guide.
Crontab Syntax
Each line in the crontab file represents a single task. The syntax is as follows:
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of the month (1 - 31)
│ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
│ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
│ │ │ │ │
│ │ │ │ │
* * * * * command to execute
You can use * for any value, or provide specific numbers. Ranges (2-5) and lists (2,5) are also supported.
Special Nicknames
For convenience, you can use the following special nicknames instead of the five-field time specification:
| Nickname | Equivalent | Description |
|---|---|---|
@hourly |
0 * * * * |
Run once an hour at the beginning of the hour. |
@daily |
0 0 * * * |
Run once a day at midnight. |
@midnight |
0 0 * * * |
(Same as @daily) |
@weekly |
0 0 * * 0 |
Run once a week on Sunday midnight. |
@monthly |
0 0 1 * * |
Run once a month on the 1st, at midnight. |
@yearly |
0 0 1 1 * |
Run once a year on Jan 1st, at midnight. |
@annually |
0 0 1 1 * |
(Same as @yearly) |
Examples
Here are some example crontab entries:
# Run a script every 15 minutes
*/15 * * * * python C:\Users\MyUser\scripts\my_script.py
# Run a backup at 5 a.m. every day
0 5 * * * tar -zcf /var/backups/home.tgz /home/
# Use a special nickname to run a task hourly
@hourly echo "This runs every hour" >> C:\temp\hourly.log
# Run a task on the first day of every month
0 0 1 * * echo "Monthly report generation"
# Run a task every Monday at 8:00 AM
0 8 * * MON python C:\path\to\your\script.py
Start Crontab at Startup
To run the crontab scheduler automatically when Windows starts, you can create a simple batch file.
-
Create a new file named
crontab_startup.bat. -
Add the following content to the file:
@echo off start /min ctab
-
Place this batch file in your startup folder. You can open the startup folder by pressing
Win + R, typingshell:startup, and pressing Enter.
Development
To contribute to this tool, first check out the code. Then create a new virtual environment:
cd crontab-win
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
python -m pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crontab_win-0.2.0.tar.gz.
File metadata
- Download URL: crontab_win-0.2.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6bbd0c0e84fb070958070b3d626dc578f90db0bcbbd0c7d01e98fa9da20d56f
|
|
| MD5 |
5ec5ef9fb291817f162d05f2bb9a4810
|
|
| BLAKE2b-256 |
c575e147de189ed1b7f299aa4a48a9a79d2c5d121391d47319a71906be921100
|
Provenance
The following attestation bundles were made for crontab_win-0.2.0.tar.gz:
Publisher:
publish.yml on sukhbinder/crontab-win
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crontab_win-0.2.0.tar.gz -
Subject digest:
d6bbd0c0e84fb070958070b3d626dc578f90db0bcbbd0c7d01e98fa9da20d56f - Sigstore transparency entry: 757713643
- Sigstore integration time:
-
Permalink:
sukhbinder/crontab-win@01e88b99f88e0e3328b4ac0bedb3c5efd644a9bf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/sukhbinder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01e88b99f88e0e3328b4ac0bedb3c5efd644a9bf -
Trigger Event:
release
-
Statement type:
File details
Details for the file crontab_win-0.2.0-py3-none-any.whl.
File metadata
- Download URL: crontab_win-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebb5ea9da73a6d8d528dda90cb9f79d750370e8284c1eea98f63259eb0fee077
|
|
| MD5 |
d5f19e3b84678bc2f764f37518dc4c2e
|
|
| BLAKE2b-256 |
d1368f73d29017f5dfcd295122672e30719a91a6575630984a7ee811947c2594
|
Provenance
The following attestation bundles were made for crontab_win-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on sukhbinder/crontab-win
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crontab_win-0.2.0-py3-none-any.whl -
Subject digest:
ebb5ea9da73a6d8d528dda90cb9f79d750370e8284c1eea98f63259eb0fee077 - Sigstore transparency entry: 757713645
- Sigstore integration time:
-
Permalink:
sukhbinder/crontab-win@01e88b99f88e0e3328b4ac0bedb3c5efd644a9bf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/sukhbinder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01e88b99f88e0e3328b4ac0bedb3c5efd644a9bf -
Trigger Event:
release
-
Statement type: