mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
chore(kb/cron): add warning about quoting the percent char
This commit is contained in:
@@ -31,6 +31,8 @@ All crontab files:
|
|||||||
- Must be either regular files or symlinks to regular files.
|
- Must be either regular files or symlinks to regular files.
|
||||||
- Must **not** be executable **nor** writable for anyone else but the owner.<br/>
|
- Must **not** be executable **nor** writable for anyone else but the owner.<br/>
|
||||||
This requirement can be overridden by using the `-p` option on `crond`'s command line.
|
This requirement can be overridden by using the `-p` option on `crond`'s command line.
|
||||||
|
- Must escape the `%` character in commands, if used (e.g., in `date`'s formatting).<br/>
|
||||||
|
Cron interprets `%` as a newline. Everything after it is sent to the command's stdin, not as part of the command.
|
||||||
|
|
||||||
> [!important]
|
> [!important]
|
||||||
> If `inotify` support is in use, changes in symlinked crontabs are **not** automatically noticed by the cron daemon.
|
> If `inotify` support is in use, changes in symlinked crontabs are **not** automatically noticed by the cron daemon.
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
## TL;DR
|
## TL;DR
|
||||||
|
|
||||||
|
> [!caution]
|
||||||
|
> Escape the `%` character if used in commands (e.g., in `date`'s formatting), even if in quotes.<br/>
|
||||||
|
> Cron interprets `%` as a newline. Everything after it is sent to the command's stdin, not as part of the command.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# List existing jobs.
|
# List existing jobs.
|
||||||
crontab -l
|
crontab -l
|
||||||
@@ -35,7 +39,9 @@ sudo crontab -r -u 'nana'
|
|||||||
*/10 * * * * ls
|
*/10 * * * * ls
|
||||||
|
|
||||||
# Run a script at 02:34 every Friday.
|
# Run a script at 02:34 every Friday.
|
||||||
|
# `%` needs escaping even in quotes
|
||||||
34 2 * * Fri /absolute/path/to/script.sh
|
34 2 * * Fri /absolute/path/to/script.sh
|
||||||
|
35 3 * * FRI /absolute/path/to/script.sh > /absolute/path/to/script.$(date '+\%F').log
|
||||||
```
|
```
|
||||||
|
|
||||||
## Further readings
|
## Further readings
|
||||||
|
|||||||
Reference in New Issue
Block a user