webCOMAND

CLI Tasks

To schedule a command-line interface script, application or daemon to run, in webCOMAND add the CLI, CLI Runnable and Scheduled Task object as outline below.

  1. Package - Determine an existing Package this task will be added to, or add a new Package.
  2. CLI App - In webCOMAND or the file system, add a PHP script or other CLI software application that can be executed from the CLI.
  3. CLI Runnable - In webOCMAND, open the Package where you would like to define the task and add a new CLI Runnable.
    • Identifier - A name to uniquely identify this Runnable from all others.  This is like a variable name that can be used to reference this runnable from code.
    • Title - Friendly title for this task, which will be visible in webCOMAND.
    • Run As - Optional User to run this task as.  If not selected, the task will run as the admin user which has unlimited access to the webCOMAND repository.  If you prefer to restrict this process, you can select another User to limit the process to that User's authorizations.
    • Retention - The number of hours a record of each time the task is run will be retained, along with any event logs and other information.  If left as zero, it will be retained indefinitely and must be removed manually or from another process.  It is a good idea to set this to avoid a build up of System Task records.
    • Package - Select the package determined in step 1 above.  This is the package that contains the cli folder where the system will look for the Script.
    • Script - The filename of the CLI App in the Package cli folder from step 2 above.
  4. Scheduled Task - In webCOMAND, open the Package where you would like to define the Scheduled Task, which contains the rules for when and how to run the CLI App.
    • Title - Friendly title for this task, which will be visible in webCOMAND and related emails.
    • User - Optional User to run this task as.  If not selected, the CLI Runnable "Run As" user defined in step 3 above will be used.
    • Email - If and when to send an email after this task has completed.
    • Email To - Where to send emails after this task has completed.
    • Retries - The number of times this scheduled task should be repeated in the event that a failure occurs (that is, when an "Unexpectedly Terminated" process status is encountered). 0 indicates that the task will not be retried (the default), 1 indicates that it will be retried once, etc.
    • Timeout - If set, and if an 'On Timeout' action is selected, this is the number of seconds after which the 'On Timeout' action will be taken.  0 implies that the process will never timeout.
    • On Timeout - If set, and if a non-0 'Timeout' is defined, this action will be taken when the process execution exceeds 'Timeout' seconds. Processes that are canceled or killed for exceeding their max runtime will not be automatically retried.
    • Runnables - The runnable content to invoke for this scheduled task.  This is the CLI Runnable added in step 2 above.
    • Parameters - An optional JSON array of parameters to use in this scheduled task. This array's length should be exactly equal to the number of selected Runnables, and holding at each index an associative or non-associative array of parameters to pass in to each Runnable respectively. For example:
      [
          [
              "CLI param 1",
              "CLI param 2"
          ]
      ]
    • Retention - The amount of time, in hours, that SystemTasks generated from this ScheduledTask should be left in the system before they are automatically purged. If 0, they are never removed.
    • Active - This scheduled task will only be run if marked as active.
    • Server Types - The server types that this task will be able to run on. The configured webCOMAND server_type value will be compared to this field, and only tasks matching the server type will be able to be run.
    • Groups - A comma-separated list of group names that this task is associated with. Groups defined here are used in conjunction with BlockedBy to queue tasks that shouldn't run at the same time as one-another.
    • Blocked By - A comma-separated list of groups that this task will be blocked by. This task will not start if other tasks with these groups are already running. '*' can also be used to be blocked by any other running tasks.
    • Run As Service - When checked, this task will be run as a service and always available in the background. No scheduled times will be required because the daemon will always ensure that this is running.
    • Scheduled Times - The set of schedule times that define when this task should be run.

Once scheduled, a Scheduled Task will be added each time the CLI task is run, which will include the status of the task while it is running and after it has completed, including any logged events.