Update cron.md (#2116)

Added missing special strings for crontab
This commit is contained in:
Daniel Metzler 2024-03-15 14:24:53 +01:00 committed by GitHub
parent d4cac4c37e
commit 4f18d6a46b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 10 deletions

29
cron.md
View File

@ -2,7 +2,7 @@
title: Cron
category: CLI
layout: 2017/sheet
updated: 2018-05-03
updated: 2024-03-17
weight: -3
---
@ -39,6 +39,18 @@ Min Hour Day Mon Weekday
| `-` | a range of values |
| `/` | divide a value into steps |
### Special strings
| String | Description |
| --- | --- |
| `@reboot` | every rebot |
| `@hourly` | once every hour - same as `0 * * * *` |
| `@daily` | once every day - same as `0 0 * * *` |
| `@midnight` | once every midnight - same as `@daily` |
| `@weekly` | once every week - same as `0 0 * * 0` |
| `@monthly` | once every month - same as `0 0 1 * *` |
| `@yearly` | once every year - same as `0 0 1 1 *` |
### Examples
| Example | Description |
@ -49,22 +61,19 @@ Min Hour Day Mon Weekday
| `0 18 * * 0-6` | every week Mon-Sat at 6pm |
| `10 2 * * 6,7` | every Sat and Sun on 2:10am |
| `0 0 * * 0` | every Sunday midnight |
| --- | --- |
| `@reboot` | every reboot |
### Crontab
```bash
# Adding tasks easily
echo "@reboot echo hi" | crontab
```
```bash
# Open in editor
crontab -e
```
# Open in editor - optional for another user
crontab -e [-u user]
```bash
# List tasks
# List tasks - optional for another user
crontab -l [-u user]
# Delete crontab file - optional for another user
crontab -r [-u user]
```