> For the complete documentation index, see [llms.txt](https://kwcsec.gitbook.io/the-red-team-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kwcsec.gitbook.io/the-red-team-handbook/techniques/persistence/scheduled-tasks.md).

# Scheduled Tasks

Scheduled tasks are used to execute or do a certain action at a set period of time.

Scheduled tasks can be used for userland or elevated persistence. There is a lot of flexibility on how to configure and when to trigger the task, these can be checked issuing “schtasks.exe /?"

An example of this is this one, where it will run everyday at 10:00

```
schtasks /create /tn ”tenoclock" /tr C:\executable /sc daily /st 10:00
```

or when the user's session is idle for 10 minutes

```
schtasks /create /tn "NotEvil" /tr NotEvil /sc onidle /i 10
```

To execute as system, we can add the following flag: `/ru System`
