takuya/php-atq-wrapper

atq/atrm php wrapper class

1.0 2021-03-05 19:16 UTC

This package is auto-updated.

Last update: 2024-12-06 02:57:26 UTC


README

'atq/at' scheduled job timer command line wrapper.

what is atq

atq/at is pre-installd majaor linux dist. alarm or scheduling timer run once at specified.

https://manpages.debian.org/jessie/at/at.1.en.html

Install

composer require takuya/php-atq-wrapper

Samples

add/show/remove atq job

<?php
    use SystemUtil\AtJobs;
    $at_job = new AtJobs( 'ssh server docker exec ubuntu1604 -- at' );
    $id = $at_job->add( '+30days', 'echo Hello 2','s' );
    $at_job->exists($id);// => true
    $at_job->get_body( $id ); //=> /bin/sh body will be executed.
    $at_job->remove($id); //=> cancel job.

list current queued jobs.

<?php
    use SystemUtil\AtJobs;
    $at_job = new AtJobs( 'ssh server docker exec ubuntu1604 -- at' );
    foreach ($at_job->queue() as $job) {
      $job->id;
      $job->start;
      $job->q;
      $job->user;
      $job->body();
    }

Cancel Jobs

<?php
    use SystemUtil\AtJobs;
    $at_job = new AtJobs( 'ssh server docker exec ubuntu1604 -- at' );
    foreach ($at_job->queue('a') as $job) {
      $job->remove();
    }