Skip to main content

Automate scripts with zero setup. Run Python tasks anytime, anywhere.

Project description

AutoCron ⏰

PyPI version Python Support Platform License: MIT CI/CD codecov

Schedule Python tasks with one line of code. Works everywhere.

AutoCron makes task scheduling painless—no cron syntax, no platform-specific setup. Just Python.


🚀 Quick Start

Install:

pip install autocron-scheduler

Schedule a task:

from autocron import schedule

@schedule(every='5m')
def my_task():
    print("Running every 5 minutes!")

That's it. AutoCron handles the rest.


✨ Why AutoCron?

Feature AutoCron cron/Task Scheduler
🌍 Cross-platform ✅ Windows, Linux, macOS ❌ Platform-specific
💻 Pure Python ✅ No system config ❌ Requires system setup
🔄 Retry logic ✅ Built-in ❌ Manual implementation
📊 Logging ✅ Automatic ❌ Manual setup
🔔 Notifications ✅ Desktop + Email ❌ Not included
⚡ Type hints ✅ Fully typed N/A

📦 Installation

Basic:

pip install autocron-scheduler

With notifications:

pip install autocron-scheduler[notifications]

From source:

git clone https://github.com/mdshoaibuddinchanda/autocron.git
cd autocron
pip install -e .

💡 Examples

Simple Decorator

from autocron import schedule

@schedule(every='30m')
def fetch_data():
    # Runs every 30 minutes
    print("Fetching data...")

@schedule(cron='0 9 * * *')  # Every day at 9 AM
def daily_report():
    print("Generating report...")

Scheduler Class

from autocron import AutoCron

scheduler = AutoCron()

scheduler.add_task(
    name="backup",
    func=backup_database,
    every='1h',
    retries=3,
    notify='desktop'
)

scheduler.start()

With Retry & Timeout

@schedule(every='10m', retries=3, timeout=60)
def api_call():
    # Retries up to 3 times, max 60 seconds
    response = requests.get('https://api.example.com/data')
    return response.json()

Email Notifications

scheduler.add_task(
    name="critical_task",
    func=process_payments,
    cron='0 */4 * * *',  # Every 4 hours
    notify='email',
    email_config={
        'smtp_server': 'smtp.gmail.com',
        'smtp_port': 587,
        'from_email': 'YOUR_EMAIL@gmail.com',
        'to_email': 'ADMIN_EMAIL@gmail.com',
        'password': 'YOUR_APP_PASSWORD_HERE'
    }
)

📖 Time Formats

Intervals:

  • '30s' → Every 30 seconds
  • '5m' → Every 5 minutes
  • '2h' → Every 2 hours
  • '1d' → Every day

Cron expressions:

  • '0 9 * * *' → Daily at 9 AM
  • '*/15 * * * *' → Every 15 minutes
  • '0 0 * * 0' → Sundays at midnight
  • '0 12 * * 1-5' → Weekdays at noon

🛠️ CLI

# Schedule from command line
autocron schedule script.py --every 5m --retries 3

# List tasks
autocron list

# View logs
autocron logs task_name

🎯 Use Cases

  • Data pipelines – ETL jobs, backups, syncs
  • Web scraping – Periodic data collection
  • Monitoring – Health checks, API status
  • Reports – Automated daily/weekly reports
  • Maintenance – Log cleanup, cache clearing

📚 Documentation

📖 New to AutoCron? Check out our Complete Guide for detailed examples, production setup, and platform-specific instructions!


🧪 Testing

AutoCron is tested across 12 combinations (3 OS × 4 Python versions):

pytest                    # Run all tests
pytest --cov=autocron     # With coverage
pytest -m linux           # Platform-specific

Test matrix:

  • ✅ Windows, Linux, macOS
  • ✅ Python 3.10, 3.11, 3.12, 3.13, 3.14
  • ✅ 82/84 tests passing (69% coverage)

🤝 Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.


📝 License

MIT License – see LICENSE for details.


🔗 Links


Made with ❤️ by mdshoaibuddinchanda

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autocron_scheduler-1.0.2.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autocron_scheduler-1.0.2-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file autocron_scheduler-1.0.2.tar.gz.

File metadata

  • Download URL: autocron_scheduler-1.0.2.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for autocron_scheduler-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c8fd35e2e1bf17b607106c1314afad226d1c905769e301236be133fdc28ccc92
MD5 f21a6d3153ea375b35006c9dd9c3402e
BLAKE2b-256 3c38d085bc1df9cba59a549bbc572cce4be357731a2eed89a462b4ddb673e58e

See more details on using hashes here.

File details

Details for the file autocron_scheduler-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for autocron_scheduler-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50f7b257ecd81e1f37af3115b823e9951cedf2a2df7bda9bf837c2c3363b50ec
MD5 b5c0c6c1bc48e48f6b603f5dce492abc
BLAKE2b-256 d461738dce179a3a8b4631369e9655b32129fa833a1c3a6c17c0ec60f5727e23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page