From 5b25000fa4939c3b0dde12ef3fc354916ee7309d Mon Sep 17 00:00:00 2001 From: FireIsGood Date: Thu, 16 May 2024 03:28:47 -0700 Subject: [PATCH] fix: cron format Fixes the spacing and tabel formatting --- source/_posts/cron.md | 106 +++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 58 deletions(-) diff --git a/source/_posts/cron.md b/source/_posts/cron.md index 5c7fb00..04940b3 100644 --- a/source/_posts/cron.md +++ b/source/_posts/cron.md @@ -3,20 +3,18 @@ title: Cron date: 2020-12-16 18:28:43 background: bg-red-500 tags: - - schedule - - crontab - - time + - schedule + - crontab + - time categories: - - Linux Command + - Linux Command intro: | - [Cron](https://en.wikipedia.org/wiki/Cron) is most suitable for scheduling repetitive tasks. Scheduling one-time tasks can be accomplished using the associated at utility. + [Cron](https://en.wikipedia.org/wiki/Cron) is most suitable for scheduling repetitive tasks. Scheduling one-time tasks can be accomplished using the associated at utility. plugins: - - copyCode + - copyCode --- - -Crontab Format {.cols-2} ------- +## Crontab Format {.cols-2} ### Format @@ -24,7 +22,7 @@ Crontab Format {.cols-2} Min Hour Day Mon Weekday ``` -------- +--- ``` * * * * * command to be executed @@ -39,81 +37,73 @@ Min Hour Day Mon Weekday └───────────────────── Minute (0..59) ``` ------- ------- +--- | Field | Range | Special characters | -|--------------|--------|--------------------| -| Minute | 0 - 59 | , - * / | -| Hour | 0 - 23 | , - * / | -| Day of Month | 1 - 31 | , - * ? / L W | -| Month | 1 - 12 | , - * / | -| Day of Week | 0 - 6 | , - * ? / L # | -{.show-header} +| ------------ | ------ | ------------------ | +| Minute | 0 - 59 | , - \* / | +| Hour | 0 - 23 | , - \* / | +| Day of Month | 1 - 31 | , - \* ? / L W | +| Month | 1 - 12 | , - \* / | +| Day of Week | 0 - 6 | , - \* ? / L # | +{.show-header} ### Examples -| Example | Description | -|----------------|------------------------| -| `*/15 * * * *` | Every 15 mins | -| `0 * * * *` | Every hour | -| `0 */2 * * *` | Every 2 hours | -| `15 2 * * *` | At 2:15AM of every day | -| `15 2 * * ?` | At 2:15AM of every day | - -| `10 9 * * 5` | At 9:10AM of every Friday | -| `0 0 * * 0` | At midnight of every Sunday | - -| `15 2 * * 1L` | At 2:15am on the last monday of every month | -| `15 0 * * 4#2` | At 00:15am on the second thursday of every month | -| `0 0 1 * *` | Every 1st of month (monthly) | -| `0 0 1 1 *` | Every 1st of january (yearly) | - -| `@reboot` | Every reboot
_(non-standard)_ | - +| Example | Description | +| -------------- | ------------------------------------------------ | +| `*/15 * * * *` | Every 15 mins | +| `0 * * * *` | Every hour | +| `0 */2 * * *` | Every 2 hours | +| `15 2 * * *` | At 2:15AM of every day | +| `15 2 * * ?` | At 2:15AM of every day | +| `10 9 * * 5` | At 9:10AM of every Friday | +| `0 0 * * 0` | At midnight of every Sunday | +| `15 2 * * 1L` | At 2:15am on the last monday of every month | +| `15 0 * * 4#2` | At 00:15am on the second thursday of every month | +| `0 0 1 * *` | Every 1st of month (monthly) | +| `0 0 1 1 *` | Every 1st of january (yearly) | +| `@reboot` | Every reboot
_(non-standard)_ | ### Special strings -| Special String | Meaning | -|----------------|----------------------------------------------------| -| @reboot | Run once, at system startup _(non-standard)_ | -| @yearly | Run once every year, "0 0 1 1 *" _(non-standard)_ | -| @annually | (same as @yearly) _(non-standard)_ | -| @monthly | Run once every month, "0 0 1 * *" _(non-standard)_ | -| @weekly | Run once every week, "0 0 * * 0" _(non-standard)_ | -| @daily | Run once each day, "0 0 * * *" _(non-standard)_ | -| @midnight | (same as @daily) _(non-standard)_ | -| @hourly | Run once an hour, "0 * * * *" _(non-standard)_ | - +| Special String | Meaning | +| -------------- | ---------------------------------------------------- | +| @reboot | Run once, at system startup _(non-standard)_ | +| @yearly | Run once every year, "0 0 1 1 \*" _(non-standard)_ | +| @annually | (same as @yearly) _(non-standard)_ | +| @monthly | Run once every month, "0 0 1 \* \*" _(non-standard)_ | +| @weekly | Run once every week, "0 0 \* \* 0" _(non-standard)_ | +| @daily | Run once each day, "0 0 \* \* \*" _(non-standard)_ | +| @midnight | (same as @daily) _(non-standard)_ | +| @hourly | Run once an hour, "0 \* \* \* \*" _(non-standard)_ | ### Crontab command - | - | - | -|--------------|-------------------------------------------------------------------------| +| ------------ | ----------------------------------------------------------------------- | | `crontab -e` | Edit or create a crontab file if doesn’t already exist. | | `crontab -l` | Display the crontab file. | | `crontab -r` | Remove the crontab file. | | `crontab -v` | Display the last time you edited your crontab file.
_(non-standard)_ | + {.shortcuts} - ### Special characters {.col-span-2} + | Special Character | Description | -|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `Asterik(*)` | Matches all values in the field or any possible value. | | `Hyphen(-)` | Used to define a range.Ex: 1-5 in 5th field(Day Of Week) Every Weekday i.e., Monday to Friday | | `Slash (/)` | 1st field(Minute) /15 meaning every fifteen minute or increment of range. | | `Comma (,)` | Used to separate items.Ex: 2,6,8 in 2nd fields(Hour) executes at 2am,6am and 8am | | `L` | It is allowed only for Day of Month or Day Of Week field, 2L in Day of week indicates Last tuesday of every month | | `Hash (#)` | It is allowed only for Day Of Week field, which must be followed within range of 1 to 5. For example, 4#1 means "The first Thursday" of given month. | -| `Question mark (?)` | Can be instead of '*' and allowed for Day of Month and Day Of Week. Usage is restricted to either Day of Month or Day Of Week in a cron expression. | - - +| `Question mark (?)` | Can be instead of '\*' and allowed for Day of Month and Day Of Week. Usage is restricted to either Day of Month or Day Of Week in a cron expression. | ## Also see {.cols-1} -* [Devhints](https://devhints.io/cron) _(devhints.io)_ -* [Crontab Generator](https://crontab-generator.org/) _(crontab-generator.org)_ -* [Crontab guru](https://crontab.guru/) _(crontab.guru)_ +- [Devhints](https://devhints.io/cron) _(devhints.io)_ +- [Crontab Generator](https://crontab-generator.org/) _(crontab-generator.org)_ +- [Crontab guru](https://crontab.guru/) _(crontab.guru)_