auguzsto/cronjob 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

auguzsto/cronjob

最新稳定版本:0.0.6

Composer 安装命令:

composer require auguzsto/cronjob

包简介

(PHP Cron) Asynchronous task scheduler without the need for extensions.

README 文档

README

(PHP Cron) Asynchronous task scheduler without the need for extensions. Written in PHP for PHP.

Setting up

Install package

composer require auguzsto/cronjob

Create the folder for the tasks, preferably at the root of your project.

mkdir tasks

Next step is to set the CRONJOB_TASKS_DIR environment variable with the absolute path of the task path.

CRONJOB_TASKS_DIR=/example/app/tasks

Creating task

vendor/bin/cronjob create ExampleTask

This command will create a class in your tasks folder with a skeleton already in place.

<?php

use Auguzsto\Cronjob\TaskInterface;
use Auguzsto\Cronjob\SchedulerInterface;

class ExampleTask implements TaskInterface
{
    /**
     * Schedule
     * $scheduler->on("* * * * *", new self);
     */
    public static function toScheduler(SchedulerInterface $scheduler): void 
    {
        $scheduler->on("0 0 * * *", new self);
    }

    /**
     * Implement the task to be performed
     */
    public static function onTask(): void
    {
        file_put_contents("backup.txt", "backup");
    }
}

toScheduler() is used to set the task's period in cron format (* * * * *).

onTask() is the method that will be executed.

Turn on the service

vendor/bin/cronjob start

Done! Your scheduling service is up and running.

Commands

Turn off the service

vendor/bin/cronjob stop

View schedules by task

vendor/bin/cronjob schedules ExampleTask

View all scheduler errors

vendor/bin/cronjob errors

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-17