---
name: "KEYCTL_SET_TIMEOUT"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/KEYCTL_SET_TIMEOUT"
---

# KEYCTL\_SET\_TIMEOUT(2const)

set the expiration timer on a key

## NAME

KEYCTL\_SET\_TIMEOUT - set the expiration timer on a key

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <linux/keyctl.h>  /* Definition of KEY* constants */
#include <sys/syscall.h>   /* Definition of SYS_* constants */
#include <unistd.h>
```

**long syscall(SYS\_keyctl, KEYCTL\_SET\_TIMEOUT, key\_serial\_t** *key***, time\_t** *t***);**

## DESCRIPTION

Set a timeout on a key.

The ID of the key is specified in *key*. The timeout value, in seconds from the current time, is specified in *t*. The timeout is measured against the realtime clock.

Specifying the timeout value as 0 clears any existing timeout on the key.

The */proc/keys* file displays the remaining time until each key will expire. (This is the only method of discovering the timeout on a key.)

The caller must either have the *setattr* permission on the key or hold an instantiation authorization token for the key (see [**request\_key**(2)](/request_key/2.md)).

The key and any links to the key will be automatically garbage collected after the timeout expires. Subsequent attempts to access the key will then fail with the error **EKEYEXPIRED**.

This operation cannot be used to set timeouts on revoked, expired, or negatively instantiated keys.

## RETURN VALUE

On success, 0 is returned.

On error, -1 is returned, and *errno* is set to indicate the error.

## VERSIONS

A wrapper is provided in the *libkeyutils* library: [**keyctl\_set\_timeout**(3)](/keyctl_set_timeout/3.md).

## STANDARDS

Linux.

## HISTORY

Linux 2.6.16.

## SEE ALSO

[**keyctl**(2)](/keyctl/2.md), [**keyctl\_set\_timeout**(3)](/keyctl_set_timeout/3.md)
