# Cron Workflows

The Pipekit CLI provides `create` (equivalent to submit for regular workflows), `delete`, `suspend`, `resume`, and `update` commands for a CronWorkflow.

For further information about CronWorkflows, [please refer to our CronWorkflow documentation](https://docs.pipekit.io/pipekit/pipes/cron-workflows).

## Create and update Cron

To create a new CronWorkflow on a given cluster:

```bash
$> pipekit create cron --cluster-name=clusterB ./path/to/workflow.yaml
```

{% hint style="info" %}
This will create a new CronWorkflow and a Pipe based on the CronWorkflow name (part of the metadata inside the YAML). If such a Pipe already exists, a new CronWorkflow manifest will be associated with it as well.
{% endhint %}

{% hint style="warning" %}
Note: You will not be able to create two CronWorkflows with the same name, on the same cluster, in the same namespace. You must therefore check the namespace specified in the meta part of your CronWorkflow yaml.
{% endhint %}

To update an existing CronWorkflow, on a given cluster:

```bash
$> pipekit update cron --cluster-name=clusterB ./path/to/workflow.yaml
```

| Flag           | Shorthand | Type   | Description                                                |
| -------------- | --------- | ------ | ---------------------------------------------------------- |
| --cluster-name | -c        | string | name of the cluster to create a CronWorkflow on (required) |
| --namespace    | -n        | string | namespace in which the CronWorkflow is located             |

## Delete Cron

To delete a CronWorkflow, from a given cluster, in a given namespace:

```bash
$> pipekit delete cron --cluster-name=clusterB --namespace=foo cron-wf-name
```

The argument passed to this command is the name of the CronWorkflow (which should correspond to the Pipe name).

| Flag           | Shorthand | Type   | Description                                         |
| -------------- | --------- | ------ | --------------------------------------------------- |
| --cluster-name | -c        | string | name of the cluster from which to delete (required) |
| --namespace    | -n        | string | namespace in which the CronWorkflow is located      |

## Suspend and resume Cron

Suspending a CronWorkflow means to stop it from scheduling any new Workflows. The Pipekit CLI lets you suspend a specific CronWorkflow in a given cluster and namespace, without suspending all CronWorkflows in a given Pipe.

{% hint style="info" %}
See [Disabling a Pipe](https://docs.pipekit.io/pipekit/pipes/managing-pipes#disabling-a-pipe) for suspending at the Pipe level in the UI.
{% endhint %}

To suspend a CronWorkflow, on a given cluster, in a given namespace:

```bash
$> pipekit suspend cron --cluster-name=clusterB --namespace=staging cron-wf-name
```

To resume a suspended CronWorkflow, on a given cluster, in a given namespace:

```bash
$> pipekit resume cron --cluster-name=clusterB --namespace=staging cron-wf-name
```

The only argument that these commands accept is the name of the CronWorkflow to suspend/resume.

| Flag           | Shorthand | Type   | Description                                          |
| -------------- | --------- | ------ | ---------------------------------------------------- |
| --cluster-name | -c        | string | name of the cluster from which to suspend (required) |
| --namespace    | -n        | string | namespace in which the CronWorkflow is located       |

{% hint style="warning" %}
Note: The only way to suspend and resume a *specific* CronWorkflow, on a given cluster, in a given namespace *without* suspending or resuming the CronWorkflows on other clusters and namespaces is to use the Pipekit CLI. The toggle for a Pipe in the Pipekit web interface will suspend and resume *ALL* CronWorkflows within the Pipe.
{% endhint %}

## Trigger Cron

To run a CronWorkflow immediately, on a given cluster, in a given namespace:

```bash
$> pipekit trigger cron --cluster-name=clusterB --namespace=staging cron-wf-name
```

The only argument that this command accepts is the name of the CronWorkflow to trigger.

| Flag           | Shorthand | Type   | Description                                                                   |
| -------------- | --------- | ------ | ----------------------------------------------------------------------------- |
| --cluster-name | -c        | string | name of the cluster from which to suspend (required)                          |
| --namespace    | -n        | string | namespace in which the CronWorkflow is located                                |
| --open-ui      |           | bool   | open the Pipekit web interface in your browser for the submitted workflow run |
| --wait         | -w        | bool   | wait for the submitted workflow to complete                                   |
