acrnogor/crontab-manager-bundle

适用于SF 3.4.x和4.x项目的Crontab Manager bundle

v0.9.0 2020-12-11 14:58 UTC

This package is auto-updated.

Last update: 2024-09-11 23:28:52 UTC


README

安装

使用Composer安装包

composer require acrnogor/crontab-manager-bundle 

Symfony 3.4.*

添加配置

  • %PROJECT_DIR%/app/config/config.yml,例如
acrnogor_crontab_manager:
    cron_jobs:
        - '*/8 * * * * /usr/bin/php /var/www/test/test.php > /dev/null 2>&1'

将bundle包含到你的Kernel中 %PROJECT_DIR%/app/Kernel.php

<?php

$bundles = [
    // ... previous bundles
    new Acrnogor\CrontabManagerBundle\AcrnogorCrontabManagerBundle()
];

在你的 parameters.yml 中添加参数

parameters: 
    # ...
    crontab_user: www-data

就完成了。跳转到控制台。

Symfony ^4.0

创建symfony配置yaml文件

  • %PROJECT_DIR% /config/packages/acrnogor_crontab_manager.yml,例如
acrnogor_crontab_manager:
  cron_jobs:
    - '*/8 * * * * /usr/bin/php /var/www/test/test.php > /dev/null 2>&1'
    - '*/8 * * * * /usr/bin/php /var/www/sf4/bin/console debug:router > /dev/null 2>&1'

将bundle添加到项目中 - 修改你的 config/bundles.php 并添加bundle,如下所示

<?php
return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Acrnogor\CrontabManagerBundle\AcrnogorCrontabManagerBundle::class => ['all' => true]
];

在你的 parameters.yml 中添加参数

parameters: 
    # ...
    crontab_user: www-data

控制台

检查你的更新crontab的命令是否在项目文件夹内工作

$ bin/console list acrnogor

应显示你的新命令。运行此命令以使用在配置中定义的cron-jobs更新你的crontab。

$ bin/console acrnogor:crontab:update