> For the complete documentation index, see [llms.txt](https://smallso.gitbook.io/tencent-cloud-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/function-trigger/use-timer.md).

# use\_timer 方法

## 简要

配置使用定时触发器。[什么是定时触发器？](https://cloud.tencent.com/document/product/583/9708)

```python
def use_timer(self,
    timer_name: str,
    timer_cron: str
)
```

## 参数

该方法具有以下参数，其参数、参数类型和参数描述如下：

| 参数          | 类型  | 必选 | 描述                                                                                                                  |
| ----------- | --- | -- | ------------------------------------------------------------------------------------------------------------------- |
| timer\_name | str | 是  | <p>定时触发器的唯一名称。<br>绑定该触发器的无服务器云函数可通过触发事件获得该触发器的唯一名称。</p>                                                             |
| timer\_cron | str | 是  | <p>定时触发器触发周期标准 Cron 表达式。</p><p><a href="https://cloud.tencent.com/document/product/583/9708">如何编写 Cron 表达式？</a></p> |

## 返回值

该方法返回当前代表触发器配置的 [FunctionTrigger](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/function-trigger) 类实例本身。

## 异常

该方法可能会主动引发的异常类型如下：

#### ValueError

参数值或类型不符合预期。

## 示例

下面我们将通过一段 Python 代码向您演示如何使用该方法：

```python
functions.FunctionTrigger.use_timer(
    timer_name = 'default',
    timer_cron = '* * * * *'
)
```

## 适用于

#### Tencent Cloud SDK for Python

产品软件包：tencent-cloud-sdk-serverless-functions >= 0.1.1
