All Projects → frostming → flask-crontab

frostming / flask-crontab

Licence: MIT license
Simple Flask scheduled tasks without extra daemons

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to flask-crontab

Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (+19.19%)
Mutual labels:  crontab
Cronv
A visualizer for CRONTAB
Stars: ✭ 196 (+97.98%)
Mutual labels:  crontab
xxl-job-executor-go
xxl-job 执行器(golang 客户端)
Stars: ✭ 298 (+201.01%)
Mutual labels:  crontab
Gophercron
golang 开箱即用的秒级分布式定时任务系统
Stars: ✭ 146 (+47.47%)
Mutual labels:  crontab
Crontab
Yii2 extension for crontab support
Stars: ✭ 170 (+71.72%)
Mutual labels:  crontab
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+2920.2%)
Mutual labels:  crontab
Crontabmanager
PHP library for GNU/Linux cron jobs management.
Stars: ✭ 113 (+14.14%)
Mutual labels:  crontab
threat-broadcast
威胁情报播报(停止运营)
Stars: ✭ 147 (+48.48%)
Mutual labels:  crontab
Cron Parser
Java Parser For Cron Expressions
Stars: ✭ 176 (+77.78%)
Mutual labels:  crontab
it-tools
A programing helper for developers built with Electron & Vue.js 🚀
Stars: ✭ 114 (+15.15%)
Mutual labels:  crontab
Ects
Elastic Crontab System 简单易用的分布式定时任务管理系统
Stars: ✭ 156 (+57.58%)
Mutual labels:  crontab
Docker Crontab
A docker job scheduler (aka. crontab for docker)
Stars: ✭ 159 (+60.61%)
Mutual labels:  crontab
W7 Rangine Empty
软擎是基于 Php 7.2+ 和 Swoole 4.4+ 的高性能、简单易用的开发框架。支持同时在 Swoole Server 和 php-fpm 两种模式下运行。内置了 Http (Swoole, Fpm),Tcp,WebSocket,Process,Crontab服务。集成了大量成熟的组件,可以用于构建高性能的Web系统、API、中间件、基础服务等等。
Stars: ✭ 246 (+148.48%)
Mutual labels:  crontab
Quantum Core
⌚ Cron-like job scheduler for Elixir
Stars: ✭ 1,905 (+1824.24%)
Mutual labels:  crontab
cloudtasker
Background jobs for Ruby using Google Cloud Tasks
Stars: ✭ 122 (+23.23%)
Mutual labels:  background-jobs
Crontab Ui
Easy and safe way to manage your crontab file
Stars: ✭ 1,786 (+1704.04%)
Mutual labels:  crontab
Cronsun
A Distributed, Fault-Tolerant Cron-Style Job System.
Stars: ✭ 2,493 (+2418.18%)
Mutual labels:  crontab
fast-laravel
基于Swoole的高性能HTTP服务器,加速您Laravel应用程序。
Stars: ✭ 33 (-66.67%)
Mutual labels:  crontab
flume
A blazing fast job processing system backed by GenStage & Redis.
Stars: ✭ 37 (-62.63%)
Mutual labels:  background-jobs
yii2-deferred-tasks
Yii2 extension for handling deferred tasks (background cron jobs)
Stars: ✭ 11 (-88.89%)
Mutual labels:  background-jobs

flask-crontab

Simple Flask scheduled tasks without extra daemons

PyPI PyPI - Python Version Github Action Supported Platforms

This project is strongly inspired by django-crontab, and only works on Python 3.5+. Due to the coming EOL of Python 2 on 2020/01/01, there is no plan for Python 2 support.

Quick Start

Install via pip:

$ pip install flask-crontab

Instantiate the extension in your app.py after the creation of Flask app:

from flask import Flask
from flask_crontab import Crontab

app = Flask(__name__)
crontab = Crontab(app)

If you are using App Factory pattern, you can also register the extension later:

crontab = Crontab()

def create_app():
    ...
    crontab.init_app(app)

Now create a scheduled job:

@crontab.job(minute="0", hour="6")
def my_scheduled_job():
    do_something()

An app context is automatically activated for every job run, so that you can access objects that are attached to app context. Then add the job to crontab:

$ flask crontab add

That's it! If you type in crontab -l in your shell, you can see some new lines created by flask-crontab.

Show jobs managed by current app:

$ flask crontab show

Purge all jobs managed by current app:

$ flask crontab remove

Run a specific job given by hash:

$ flask crontab run <job_hash>

See supported options via --help for every commands.

Decorator API

def job(
    minute: str = "*",
    hour: str = "*",
    day: str = "*",
    month: str = "*",
    day_of_week: str = "*",
    args: Tuple[Any, ...] = (),
    kwargs: Optional[Dict[str, Any]] = None,
) -> Callable:

The decorator accepts five arguments minute, hour, day, month, day_of_month, which are the same as crontab 5-parts time format. Any part that is not given defaults to *. Besides, job decorator accepts args and kwargs which will be passed to the decorated function as positional arguments and keywords arguments, respectively.

Configuration

Config item Description Default value
CRONTAB_EXECUTABLE The absolute path of crontab /usr/bin/crontab
CRONTAB_LOCK_JOBS Whether lock jobs when running False

License

This project is publised under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].