change formatting

input examples are now given as

```bash
input $ARG1
```

While outputs use md's '> ' sign as a quote.
This commit is contained in:
2023-06-17 21:28:20 +02:00
parent 1ba3010b81
commit ba8026e0c3
102 changed files with 2388 additions and 3211 deletions

View File

@@ -6,24 +6,29 @@ tags: [ "Documentation", "Basics" ]
The crontab program might have various names, like `cronie` or `crond`.
> sudo apt search -n ^cron
```bash
sudo apt search -n ^cron
```
Once installed, search for the service name, and start it.
> sudo systemctl list-unit-files | grep cron
```bash
sudo systemctl list-unit-files | grep cron
```
> sudo systemctl enable --now cron
```bash
sudo systemctl enable --now cron
```
You can *e*dit your crontab with:
> crontab -e
```bash
crontab -e
```
39 */3 * * * /usr/bin/updatedb
```
> 39 */3 * * * /usr/bin/updatedb
## Syntax
`* * * * *`
@@ -34,29 +39,33 @@ These five points refer to:
So '3pm every Sunday' would be:
`0 15 * * 7`
> 0 15 * * 7
Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'.
The minute is '0' (i.e. '0 minutes past three pm').
Doing the same thing, but only in February, would be:
`0 15 * 2 7`
> 0 15 * 2 7
### Full Paths
Executing something requires the full path to where it is, so you cannot simply use `apt update -y`, because cron does not know where `apt` is.
Instead, find out where it is:
> type -P apt
```bash
type -P apt
```
`/usr/bin/apt`
Then put that into the crontab:
> sudo crontab -e
```bash
sudo crontab -e
```
`40 */3 * * * /usr/bin/apt update -y`
> 40 */3 * * * /usr/bin/apt update -y
This will run `apt update -y` as root every 3 hours, at 40 minutes past the hour, e.g. 00:40, 03:40, 06:40.
@@ -65,13 +74,17 @@ This will run `apt update -y` as root every 3 hours, at 40 minutes past the hour
You can execute a script as root by putting it into a directory, instead of in the tab.
Look at the available cron directories:
> ls /etc/cron.\*
```bash
ls /etc/cron.\*
```
### Testing with runparts
Run-parts runs all executable scripts in a directory.
> run-parts /etc/cron.hourly
```bash
run-parts /etc/cron.hourly
```
## Tips
@@ -84,12 +97,16 @@ First add `HOME=/home/user`, then you can use syntax like this:
*Remember to test the script by executing that line first*:
> $HOME/.scripts/myScript.sh
```bash
$HOME/.scripts/myScript.sh
```
You can also add your regular path to your crontab as a variable (see example below).
If you're using vim as the editor, just run this at the top of your crontab:
> :r!echo PATH=$PATH
```bash
:r!echo PATH=$PATH
```
### `date` Commands