[Yandex Cloud documentation](../../../index.md) > [Yandex Serverless Containers](../../index.md) > [Concepts](../index.md) > [Trigger](index.md) > Timer

# Timer that invokes a Serverless Containers container

_Timer_ is a [trigger](index.md) that invokes a Serverless Containers [container](../container.md) on a schedule. The schedule is set as a [cron expression](#cron-expression). The cron expression uses [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) (UTC).

A timer needs a [service account](../../../iam/concepts/users/service-accounts.md) to invoke a container.

For more information about creating a timer, see [Creating a timer that invokes a container from Serverless Containers](../../operations/timer-create.md).

## Cron expression format {#cron-expression}

The fields in a cron expression are ordered as follows: `Minutes Hours Day-of-month Month Day-of-week Year`.

### Possible field values {#field-and-value}

{% note info %}

Special characters, as well as months and days of the week, are case-insensitive: `MON` is the same as `mon`.

{% endnote %}

| Field <br>name | Required <br>field | Acceptable <br>values | Supported <br>special <br>characters |
|----|----|----|----|
|`Minutes` | Yes | 0-59 | `,`, `-`, `*`, `/` |
|`Hours` | Yes| 0-23 | `,`, `-`, `*`, `/` |
|`Day of month`| Yes | 1-31 | `,`, `-`, `*`, `?`, `/`, `L`, `W` |
|`Month`| Yes | 1-12, <br>JAN-DEC | `,`, `-`, `*`, `/` |
|`Day of week`| Yes | 1-7, <br>SUN-SAT | `,`, `-`, `*`, `?`, `/`, `L`, `#`|
|`Year`| No | Empty, 1970-2099 | `,`, `-`, `*`, `/` |

### Special characters {#special-characters}

You can use the following special characters in cron expressions:
* `*`: Selects all values in the field.
    
    > `*` in the `Minutes` field: Trigger fires `every minute`.
* `?`: Selects any field value. You cannot specify `Day of month` and `Day of week` at the same time. If you have entered a value in one of these fields, put `?` in the other one.

    > `10` in `Day of month` and `?` in `Day of week`: Trigger fires on the 10th day of each month.
* `-`: Selects a range of values.
    
    > `10-12` in `Hours`: Trigger fires at 10 a.m., 11 a.m., and 12 p.m.
* `,`: Selects multiple values.

    > `MON,WED,FRI` in `Day of week`: Trigger fires on Monday, Wednesday, and Friday.
* `/`: Increments the value.

    > `0/15` in `Minutes`: Trigger fires at 0, 15, 30, and 45 minutes past each hour.
* `L`: This character has different meanings in the two fields it is valid for: 
    * In the `Day of month` field, it means the last day of the month.
    * In the `Day of week` field, it means the last day of the week, `7` (Saturday, `SAT`).
    
    > `L` in `Day of month`: Trigger fires on January 31, February 28, and so on.
* `W`: Selects the weekday nearest to the specified date.

    > `15W` in `Day of month`: Trigger fires on the weekday nearest to the 15th day of the month. If the 15th day falls on Saturday, the trigger fires on Friday the 14th.

    {% note info %}
    
    `L` and `W` in the `Day of month` field can also merge into the `LW` combination, firing the trigger on the last weekday of the month.
    
    {% endnote %}
                                                                                             
* `#`: Selects the Nth day of the month.

    > `6#3` in `Day of week`: Trigger will fire on the third Friday of the month (6 for Friday; 3 for third Friday of the month).

### Examples of cron expressions {#examples}

| Cron expression | Description |
|----|----|
| `* * * * ? *` | The trigger fires every minute. |
| `0 * ? * * *`| The trigger fires every hour. |
| `15 10 ? * * *` | The trigger fires every day at 10:15. |

## Roles required for timers to run correctly {#roles}

* To create a timer, you need a permission for the service account under which the timer runs the operation. This permission comes with the [iam.serviceAccounts.user](../../../iam/security/index.md#iam-serviceAccounts-user) and [editor](../../../iam/roles-reference.md#editor) roles or higher.
* To enable a timer, the service account needs the `serverless.containers.invoker` role for the folder with the container to be invoked by the timer.

Learn more about access management [here](../../security/index.md).

## Timer message format {#format}

After the trigger is activated, it sends the following message to the container: 

```json
{
  "messages": [
    {
      "event_metadata": {
        "event_id": "a1s41g2n5g0o********",
        "event_type": "yandex.cloud.events.serverless.triggers.TimerMessage",
        "created_at": "2019-12-04T12:05:14.227761Z",
        "cloud_id": "b1gvlrnlei4l********",
        "folder_id": "b1g88tflru0e********"
      },
      "details": {
        "trigger_id": "a1sfe084v4se********",
        "payload": "payload-message"
      }
    }
  ]
}
```

## Useful links {#see-also}

* [Timer that invokes a Cloud Functions function](../../../functions/concepts/trigger/timer.md)
* [Timer that sends messages to WebSocket connections](../../../api-gateway/concepts/trigger/timer.md)