Validating Crontab Entries with PHP

后端 未结 7 1138
青春惊慌失措
青春惊慌失措 2020-11-29 05:43

What is the best way to validate a crontab entry with PHP? Should I be using a regex, or an external library? I\'ve got a PHP script that adds/removes entries from a crontab

7条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 06:22

    There is a nice PHP library that can be used for Cron expression validation:

    • https://github.com/mtdowling/cron-expression

    To install this library via composer:

    composer require mtdowling/cron-expression
    

    To check if Cron expression is valid

    $isValid = Cron\CronExpression::isValidExpression($expression);
    

提交回复
热议问题