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

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

With notifications:

pip install autocron[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.1.tar.gz (30.3 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.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: autocron_scheduler-1.0.1.tar.gz
  • Upload date:
  • Size: 30.3 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.1.tar.gz
Algorithm Hash digest
SHA256 fff5c75cdd0eb3a40ad16fd087ca5590a9d0ba1b077dabc6402bb0c0409d0817
MD5 2448b2e5b47c2326dab60fe8b577bed2
BLAKE2b-256 594092100b9213566802a324abd223976a66f328dd85db507dbce02c0eadf2a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autocron_scheduler-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b81c7272b13631c28ccd488aae907dbb64ce4679da9bebbc2044559c1b982a63
MD5 1c35a41c395e4c2c5fbc379fffeeff0a
BLAKE2b-256 a06a774b7f220b743c6f77011ff157a5bbe779c25a8208370d5f3eb8b5c2fdb0

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