定制 mintware-de/native-cron 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mintware-de/native-cron

最新稳定版本:v1.2.0

Composer 安装命令:

composer require mintware-de/native-cron

包简介

Manage native cron jobs with PHP

README 文档

README

This package helps you to manage and modify your native *nix crontabs.

See also mintware-de/native-cron-bundle if you're looking for a Symfony bundle.

Features

  • View / add / edit / delete system cron jobs
  • View / add / edit / delete drop in cron jobs
  • View / add / edit / delete user cron jobs
  • Fully tested (except the adapter for native file system functions)
  • Flexible / you can easily replace any important part of the package

Installation

composer require mintware-de/native-cron

Usage

<?php

declare(strict_types=1);

use MintwareDe\NativeCron\Content\BlankLine;
use MintwareDe\NativeCron\Content\CommentLine;
use MintwareDe\NativeCron\Content\CronJobLine;
use MintwareDe\NativeCron\CrontabManager;
use MintwareDe\NativeCron\Filesystem\DarwinCrontabFileLocator;
use MintwareDe\NativeCron\Filesystem\FileHandler;

require_once __DIR__.'/vendor/autoload.php';

// Create a new crontab manager
$manager = new CrontabManager(
    // with a file locator for macOS; Use DebianCrontabFileLocator for debian based distros
    new DarwinCrontabFileLocator(),

    // and a default file handler
    new FileHandler(),
);

// Read the crontab for the user max
$crontab = $manager->readUserCrontab('max');

// Display the current content of the crontab
echo $crontab->build();

$crontab
    // Add a new cronjob
    ->add(new CronJobLine('* * * * * echo "Hello World" >> /tmp/mylog'))
    // Remove all comments and blank lines
    ->removeWhere(fn ($line) => $line instanceof CommentLine || $line instanceof BlankLine);

// Display the new content of the crontab
echo $crontab->build();

// Write the crontab for the user max
// Keep in mind that reading or writing crontab files may require higher user privileges.
$manager->writeUserCrontab($crontab, 'max');

Compatibility matrix

Feature Linux macOS Win
System Cron jobs Yes Yes No
User Cron jobs Yes Yes No
Drop-In Cron jobs Yes No No

Supported platforms

At the moment are Debian based distros and macOS supported. If you need to add support for a different platform, take a look at the CrontabFileLocatorInterface and implement it for your platform.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固