Skip to content

mdshoaibuddinchanda/autocron

Repository files navigation

AutoCron ⏰

PyPI version Python Support Platform License: MIT Tests Coverage Security Score

Schedule Python tasks with one line of code. Works everywhere. Now with async support, task persistence, safe mode, and professional v2.0 architecture!

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

Status: Enterprise-ready | Professional layered architecture | 190 tests | 72% coverage | 9.2/10 quality


Quick Start

Install:

pip install autocron-scheduler[all] # With all features

Schedule a task:

from autocron import schedule

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

# Or use async!
@schedule(every='10m')
async def async_task():
 await fetch_data()

That's it. AutoCron handles the rest.


What's New in v1.3.0

Professional Architecture (Enterprise-Ready)

Restructured to layered architecture for scalability and team development!

New Structure:

  • autocron/core/ – Scheduling engine (framework-agnostic)
  • autocron/interface/ – CLI, dashboard, notifications
  • autocron/logging/ – Logging infrastructure
  • autocron/config/ – Configuration management

Benefits:

  • Ready for v2.0+ features (plugins, REST API, cloud sync)
  • Better testing (72% coverage, 190 tests)
  • Team-friendly (clear layer boundaries)
  • Backward compatible (public API unchanged)

Quality Improvements

  • 190 tests (up from 121, +57% more tests)
  • 72% coverage (up from 62.68%, +15% improvement)
  • 9.2/10 quality score (up from 8.7/10)
  • 0 flake8 errors (PEP 8 compliant)

Safe Mode (v1.2.0 Feature)

Run untrusted scripts safely with subprocess isolation and resource limits!

scheduler.add_task(
 name="untrusted_script",
 script="user_script.py",
 every="1h",
 safe_mode=True, # Subprocess isolation
 max_memory_mb=256, # Memory limit
 timeout=300 # Hard timeout
)

Features:

  • Process isolation (failures don't affect parent)
  • Memory limits (prevents OOM crashes)
  • CPU limits (prevents system lockup - Unix)
  • Timeout enforcement at OS level
  • Output sanitization (10KB limit)

Perfect for:

  • User-provided scripts (Unix/Linux/Mac with full resource limits)
  • Multi-tenant environments (subprocess isolation on all platforms)
  • Production systems with strict SLAs
  • Processing untrusted data

Note: Windows currently supports subprocess isolation and timeout, but not memory/CPU limits. Full Windows Job Objects support coming soon.

Async/Await Support

Schedule async functions natively—no extra configuration needed!

@schedule(every='5m')
async def fetch_api():
 async with aiohttp.ClientSession() as session:
 data = await session.get('https://api.example.com')
 return await data.json()

Task Persistence

Save and restore tasks across system restarts. Your schedules survive reboots!

scheduler = AutoCron()
scheduler.add_task(name="backup", script="backup.py", every="1h")

# Save tasks to file
scheduler.save_tasks("my_tasks.yaml")

# Load them back after restart
scheduler.load_tasks("my_tasks.yaml")

Visual Dashboard

Monitor task execution with beautiful terminal dashboards!

autocron dashboard # View all tasks
autocron stats task_name # Detailed analytics
autocron dashboard --live # Real-time monitoring

Why AutoCron?

Feature AutoCron schedule APScheduler cron
Cross-platform
Pure Python
Async support
Task persistence
� Safe mode
� Visual dashboard
Retry logic
Analytics
Notifications
Type hints N/A

️ Architecture

AutoCron v1.3 features a professional layered architecture designed for enterprise scalability and team collaboration.

Structure

autocron/
├── core/ # Scheduling engine (framework-agnostic)
│ ├── scheduler.py # Core AutoCron class, Task, decorators
│ ├── os_adapters.py # Platform-specific OS adapters
│ └── utils.py # Utilities and validation
├── interface/ # User-facing interfaces
│ ├── cli.py # Command-line interface
│ ├── dashboard.py # Visual monitoring dashboard
│ └── notifications.py # Email & desktop notifications
├── logging/ # Logging infrastructure
│ └── logger.py # AutoCronLogger with rotation
└── config/ # Configuration management (future)

Benefits

Separation of Concerns – Core logic independent of UI/CLI for better testing Scalability – Ready for v2.0+ features (plugins, REST API, cloud sync) Team-Ready – Clear boundaries for collaborative development Enterprise-Grade – Matches patterns from Celery, FastAPI, Prefect Backward Compatible – Public API unchanged, existing code works as-is

Why It Matters

This architecture enables:

  • Plugin System (v2.0): Add custom schedulers, storage backends, notifiers
  • REST API (v2.0): Remote task management via HTTP endpoints
  • Cloud Sync (v2.1): Sync tasks across multiple servers
  • Better Testing: Core logic testable without UI dependencies (72% coverage, 190 tests)
  • Team Development: Multiple developers can work on different layers independently

Installation

Basic:

pip install autocron-scheduler

With dashboard:

pip install autocron-scheduler[dashboard]

With all features:

pip install autocron-scheduler[all]

From source:

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

Note: AutoCron maintains backward-compatible imports. The public API works as always:

from autocron import AutoCron, schedule, show_dashboard # Works perfectly!

For advanced use cases, you can import from specific modules (v1.3.0+):

from autocron.core.scheduler import AutoCron, Task
from autocron.interface.dashboard import show_dashboard
from autocron.logging.logger import AutoCronLogger

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...")

Async Tasks (New in v1.2!)

import aiohttp
from autocron import schedule

@schedule(every='5m')
async def fetch_async():
 async with aiohttp.ClientSession() as session:
 async with session.get('https://api.example.com') as resp:
 return await resp.json()

@schedule(every='10m')
async def process_data():
 # Multiple async operations
 results = await asyncio.gather(
 fetch_data_1(),
 fetch_data_2(),
 fetch_data_3()
 )
 return results

Task Persistence (New in v1.2!)

from autocron import AutoCron

scheduler = AutoCron()

# Add tasks
scheduler.add_task(
 name="backup",
 script="backup.py",
 every='1h',
 retries=3
)

# Save to file (survives restarts!)
scheduler.save_tasks() # Saves to ~/.autocron/tasks.yaml

# Later, after system restart...
scheduler.load_tasks() # Restores all tasks
scheduler.start()

Visual Dashboard (New in v1.1!)

# View task summary
autocron dashboard

# Task details with analytics
autocron stats backup_task

# Live monitoring
autocron dashboard --live --refresh 2

Or in Python:

from autocron import show_dashboard, show_task

show_dashboard() # Display all tasks
show_task("backup_task") # Show specific task stats

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

# Dashboard and monitoring (v1.1+)
autocron dashboard # View all tasks
autocron dashboard --live # Live monitoring
autocron stats task_name # Task analytics

Use Cases

  • Data pipelines – ETL jobs, backups, syncs (with persistence!)
  • Web scraping – Periodic data collection (async support!)
  • API monitoring – Health checks, status monitoring (with dashboard!)
  • Microservices – Background jobs, async task processing
  • Reports – Automated daily/weekly reports
  • Maintenance – Log cleanup, cache clearing
  • DevOps – Deployment automation, system monitoring

️ Architecture Quality

AutoCron v1.3.0 - Enterprise-Ready: 9.2/10

Verified Metrics (Pytest --cov):

  • 190 tests passing (121 → 190, +57% test coverage expansion)
  • 72% overall coverage (62.68% → 72%, +15% improvement)
  • Scheduler: 86.64% coverage (core engine thoroughly tested)
  • Logger: 97.56% coverage (near-complete coverage)
  • Utils: 95.24% coverage (all utilities validated)
  • Notifications: 97.85% coverage (email & desktop tested)

Security Audit (Bandit):

  • 0 HIGH severity issues
  • 0 MEDIUM severity issues
  • 6 LOW severity issues (expected subprocess warnings)
  • 2,500+ lines of code analyzed

Code Quality (Flake8, Pylint, Mypy):

  • 0 flake8 errors (PEP 8 compliant)
  • 9.20/10 pylint score (excellent code quality)
  • Full type hints throughout (mypy validated)
  • Black formatted (consistent style)

Architecture Strengths:

  • Professional layered architecture (v1.3.0 restructure)
  • Separation of concerns (core/interface/logging layers)
  • Full async/await support with proper event loop handling
  • Task persistence with YAML durability
  • Subprocess isolation (safe mode) with resource limits (Unix)
  • Visual monitoring dashboard with Rich UI
  • Type hints throughout for IDE support
  • Cross-platform (Windows, Linux, macOS)

Production Features:

  • 190 comprehensive tests (unit + integration)
  • 72% test coverage (up from 62%)
  • Zero critical security issues
  • Backward-compatible public API
  • Enterprise-ready architecture for v2.0+ features

Honest Limitations:

  • Coverage at 72% (target: 85%+ for full enterprise claim)
  • Windows resource limits not yet implemented (Unix only)
  • No external security audit yet
  • Plugin system planned for v2.0

Production Readiness:

  • Ready for enterprise production workloads
  • Professional architecture matching industry leaders (Celery, Prefect)
  • Comprehensive testing with 190 tests and 72% coverage
  • ️ Windows safe mode: subprocess isolation + timeout (memory/CPU limits Unix-only)
  • v2.0 roadmap: Plugin system, REST API, cloud sync

Documentation

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


Testing

AutoCron is tested across 15 combinations (3 OS × 5 Python versions):

pytest # Run all tests
pytest --cov=autocron # With coverage report
pytest -m linux # Platform-specific tests
pytest -v # Verbose output

Test matrix:

  • Windows, Linux, macOS
  • Python 3.10, 3.11, 3.12, 3.13, 3.14
  • 190 tests passing (comprehensive coverage)
  • 72% overall coverage (enterprise-ready)
  • Async support fully tested (asyncio event loops)
  • Persistence fully tested (YAML durability)
  • Safe mode fully tested (subprocess isolation + resource limits)

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.


License

MIT License – see LICENSE for details.


Links


Made with ️ by mdshoaibuddinchanda

About

AutoCron: One-Click Python Task Scheduler. Schedule scripts across all platforms with zero setup, automatic logging, and optional notifications.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors