[Yandex Cloud documentation](../../index.md) > [Yandex Serverless Containers](../index.md) > [Getting started](index.md) > Creating a trigger > Timer

# Creating a timer that invokes a container

Create a [timer](../concepts/trigger/timer.md) that invokes a Serverless Containers [container](../concepts/container.md) every minute.

## Getting started {#before-you-begin}

1. [Create a container](../operations/index.md#create-container) to be invoked by your timer. [Application and Dockerfile examples](container.md#examples).
1. [Create a service account](../../iam/operations/sa/create.md) that will be used to invoke the container and assign it the `serverless-containers.containerInvoker` role.

## Create a timer {#timer-create}

{% note info %}

The trigger is initiated within five minutes after it is created.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder where you want to create a timer.

    1. Navigate to **Serverless Containers**.

    1. In the left-hand panel, select ![image](../../_assets/console-icons/gear-play.svg) **Triggers**.

    1. Click **Create trigger**.

    1. Under **Basic settings**:

        * Enter the trigger name: `timer`.
        * In the **Type** field, select `Timer`.
        * In the **Launched resource** field, select `Container`.

    1. Under **Timer settings**, enter `* * ? * * *` or select `Every minute`.

    1. Under **Container settings**, select a container and specify a [service account](../../iam/concepts/users/service-accounts.md) that will invoke it.

    1. Click **Create trigger**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To create a trigger that invokes a container every minute, run this command:

    ```bash
    yc serverless trigger create timer \
      --name timer \
      --cron-expression '* * ? * * *' \
      --invoke-container-id <container_ID> \
      --invoke-container-service-account-id <service_account_ID>
    ```

    Where:

    * `--name`: Timer name.
    * `--cron-expression`: Container invocation schedule specified as a [cron expression](../concepts/trigger/timer.md#cron-expression).
    * `--invoke-container-id`: Container ID.
    * `--invoke-container-service-account-id`: ID of the service account with permissions to invoke the container.

    Result:

    ```text
    id: a1sp9tj1jhar********
    folder_id: b1g4j6o69kqj********
    created_at: "2023-03-16T17:45:23.145213360Z"
    name: timer
    rule:
      timer:
        cron_expression: '* * ? * * *'
        invoke_container_with_retry:
          container_id: bbavvhra8ekc********
          service_account_id: aje1ki4ae68u********
    status: ACTIVE
    ```

- API {#api}

  You can create a timer using the [create](../triggers/api-ref/Trigger/create.md) API method.

{% endlist %}

## Check the result {#check-result}

To make sure the timer is running properly, view the container logs. They should show that the container is invoked every minute.

1. In the [management console](https://console.yandex.cloud), select the folder with your container.
1. Navigate to **Serverless Containers**.
1. Click the container to view its invocation log.
1. In the window that opens, go to **Logs** and specify the period to view them for. The default period is one hour.

## What's next {#what-is-next}

* [Read about the concepts](../concepts/trigger/index.md).
* [Learn how to create other triggers](../operations/index.md#create-trigger).