Compare commits
No commits in common. "5a1ba18176d4761b85db1e14de0c4f2ae74d29fc" and "92d14e41b5b6bb0aa6de7afdf86286c1db6cd223" have entirely different histories.
5a1ba18176
...
92d14e41b5
@ -1,12 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Joyous ASCII"
|
|
||||||
tags: [ "fun" ]
|
|
||||||
---
|
|
||||||
|
|
||||||
- `asciiquarium`
|
|
||||||
- `cbonsai -lim "$(fortune)"`
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cow=$(cowsay -l | sort -R | head -1)
|
|
||||||
fortune -s | figlet | cowsay -nf $cow | lolcat
|
|
||||||
```
|
|
114
basics/cron.md
114
basics/cron.md
@ -2,11 +2,9 @@
|
|||||||
title: "cron"
|
title: "cron"
|
||||||
tags: [ "Documentation", "Basics" ]
|
tags: [ "Documentation", "Basics" ]
|
||||||
---
|
---
|
||||||
# Cronie
|
# Cron
|
||||||
|
|
||||||
The `cronie` program is also known as `crond`.
|
The crontab program might have various names, like `cronie` or `crond`.
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt search -n ^cron
|
sudo apt search -n ^cron
|
||||||
@ -19,33 +17,29 @@ sudo systemctl list-unit-files | grep cron
|
|||||||
sudo systemctl enable --now $NAME
|
sudo systemctl enable --now $NAME
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
Make a file for your crontab, like this:
|
||||||
|
|
||||||
Show your current crontab:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crontab -l
|
echo '39 */3 * * * /usr/bin/updatedb' > "$USER".cron
|
||||||
```
|
|
||||||
|
|
||||||
You can put this in a file and edit it:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
crontab -l > $filename
|
|
||||||
echo '39 3 */3 * * /bin/tar czf /tmp/etc_backup.tgz /etc/' >> $filename
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then apply that crontab:
|
Then apply that crontab:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crontab $filename
|
crontab "$USER".cron
|
||||||
rm $filename
|
rm "$USER".cron
|
||||||
```
|
```
|
||||||
|
|
||||||
The `cron` program will check your syntax before adding the tab.
|
The `cron` program will check your syntax before adding the tab.
|
||||||
|
|
||||||
Your crontab file sits somewhere in `/var/spool/`.
|
Your crontab file sits somewhere in `/var/spool/`.
|
||||||
Probably in `/var/spool/cron`.
|
Probably in `/var/spool/cron`.
|
||||||
|
|
||||||
|
Check how your tab currently looks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
crontab -l
|
||||||
|
```
|
||||||
|
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
`* * * * *`
|
`* * * * *`
|
||||||
@ -56,61 +50,43 @@ These five points refer to:
|
|||||||
|
|
||||||
So '3pm every Sunday' would be:
|
So '3pm every Sunday' would be:
|
||||||
|
|
||||||
`0 15 * * 7`
|
> 0 15 * * 7
|
||||||
|
|
||||||
Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'.
|
Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'.
|
||||||
The minute is '0' (i.e. '0 minutes past three pm').
|
The minute is '0' (i.e. '0 minutes past three pm').
|
||||||
|
|
||||||
Doing the same thing, but only in February, would be:
|
Doing the same thing, but only in February, would be:
|
||||||
|
|
||||||
`0 15 * 2 7`
|
> 0 15 * 2 7
|
||||||
|
|
||||||
### Variables
|
### Full Paths
|
||||||
|
|
||||||
`cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it:
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo "HOME=$HOME" > $filename
|
type -P apt
|
||||||
crontab -l >> $filename
|
|
||||||
crontab $filename
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`cronie` doesn't know where anything lives, including programs.
|
`/usr/bin/apt`
|
||||||
You can give it your usual `$PATH` variable like this:
|
|
||||||
|
|
||||||
|
Then put that into the crontab:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo $PATH > $filename
|
sudo crontab -e
|
||||||
crontab -l >> $filename
|
|
||||||
crontab $filename
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Now instead of doing this
|
> 40 */3 * * * /usr/bin/apt update -y
|
||||||
|
|
||||||
`40 */3 * * * /usr/bin/du -sh $HOME/* | sort -h > $HOME/sum.txt`
|
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.
|
||||||
|
|
||||||
You can simply do this:
|
## Directories
|
||||||
|
|
||||||
`40 */3 * * * du -sh $HOME/* | sort -h > $HOME/sum.txt`
|
|
||||||
|
|
||||||
## Run as Root
|
|
||||||
|
|
||||||
You can execute a script as root by putting it into a directory, instead of in the tab.
|
You can execute a script as root by putting it into a directory, instead of in the tab.
|
||||||
Look at the available cron directories:
|
Look at the available cron directories:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ls -d /etc/cron.*
|
ls /etc/cron.\*
|
||||||
```
|
|
||||||
|
|
||||||
Make a script which runs daily:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
f=apt_update.sh
|
|
||||||
echo '#!/bin/bash' > $f
|
|
||||||
echo 'apt update --yes' >> $f
|
|
||||||
chmod +x $f
|
|
||||||
sudo mv $f /etc/cron.daily/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Testing with runparts
|
### Testing with runparts
|
||||||
@ -121,9 +97,47 @@ Run-parts runs all executable scripts in a directory.
|
|||||||
run-parts /etc/cron.hourly
|
run-parts /etc/cron.hourly
|
||||||
```
|
```
|
||||||
|
|
||||||
# Troubleshooting
|
## Tips
|
||||||
|
|
||||||
|
### Variables
|
||||||
|
|
||||||
|
Add your `$HOME` to crontab to use scripts.
|
||||||
|
First add `HOME=/home/$USER`, then you can use syntax like this:
|
||||||
|
|
||||||
|
0 * * * * $HOME/.scripts/myScript.sh
|
||||||
|
|
||||||
|
*Remember to test the script by executing that line first*:
|
||||||
|
|
||||||
|
```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:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
:r!echo PATH=$PATH
|
||||||
|
```
|
||||||
|
|
||||||
### `date` Commands
|
### `date` Commands
|
||||||
|
|
||||||
Cron doesn't understand the `%` sign, so if you want to use `date +%R`, then it should be escaped with a backslash: `date +\%R`.
|
Cron doesn't understand the `%` sign, so if you want to use `date +%R`, then it should be escaped with a backslash: `date +\%R`.
|
||||||
|
|
||||||
|
### File Location
|
||||||
|
|
||||||
|
The crontab files are in `/var/spool/cron/`, so you can backup or restore them.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```
|
||||||
|
HOME=/home/user
|
||||||
|
PATH=/usr/condabin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/user/.local/bin:/home/user/.scripts/:/home/user/.local/bin:/home/user/.scripts/
|
||||||
|
|
||||||
|
1 0 1 * * /usr/bin/mkdir -p $HOME/arc/$(date +\%Y/\%m)
|
||||||
|
|
||||||
|
18 0 1 */3 * $HOME/.scripts/mail-clean.sh
|
||||||
|
|
||||||
|
* * * * * ping -c 1 home || mail-pull.sh
|
||||||
|
|
||||||
|
50 18 * * * /usr/bin/timeout 30m /usr/bin/syncthing
|
||||||
|
|
||||||
|
```
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
title: "git-secret"
|
title: "git secret"
|
||||||
tags: [ "data", "git" ]
|
tags: [ "data", "git" ]
|
||||||
---
|
---
|
||||||
|
|
||||||
This utility is largely useless, as it can only identify people by their email.
|
This utility is largely useless, as it can only identify people by their email.
|
||||||
So if someone has multiple GPG keys associated with one email, the tool will not work.
|
So if someone has multiple GPG keys associated with one email, the tool will not work.
|
||||||
|
|
||||||
A broken tool is better than a tool which will break soon.
|
Worse than not working, it may 'suddenly' stop working as you try to transfer a secret to someone, who then discovers that `git-secret` requires them to mess about with their GPG keyring in order to use the repository.
|
||||||
|
@ -1,47 +1,33 @@
|
|||||||
---
|
---
|
||||||
title: "sc-im"
|
title: "sc-im"
|
||||||
tags: [ "Documentation", "TUI", "data" ]
|
tags: [ "Documentation", "data" ]
|
||||||
---
|
---
|
||||||
|
|
||||||
- [Sample file](sc-im/sample.sc)
|
|
||||||
|
|
||||||
# Basic Commands
|
# Basic Commands
|
||||||
|
|
||||||
## See Cells
|
> H = highest part
|
||||||
|
> L = lowest part
|
||||||
|
> gg = top
|
||||||
|
|
||||||
Cells are hard to see.
|
> g$ = most right.
|
||||||
Change this with `:set autowrap`.
|
> g0 = most left.
|
||||||
|
|
||||||
Make `sc-im` always autowrap:
|
> \ = insert middle
|
||||||
|
> \> = insert left
|
||||||
|
> < = insert right
|
||||||
|
|
||||||
```bash
|
gb4 = to to cell b4
|
||||||
mkdir .config/sc-im/bash
|
|
||||||
echo 'set autowrap' >> .config/sc-im/scimrc
|
|
||||||
```
|
|
||||||
|
|
||||||
## Movement
|
> aa = see all text in cells
|
||||||
|
> f = format cells so you can see it.
|
||||||
|
> fl = format wider right
|
||||||
|
> fh = format smaller left
|
||||||
|
|
||||||
| Command | Key |
|
> fj = format wider down
|
||||||
|:------------------------------------|:---:|
|
> fk = format smaller down
|
||||||
| highest part | H |
|
|
||||||
| lowest part | L |
|
|
||||||
| top | gg |
|
|
||||||
| most right. | g$ |
|
|
||||||
| most left. | g0 |
|
|
||||||
| insert middle | \ |
|
|
||||||
| insert left | \> |
|
|
||||||
| insert right | < |
|
|
||||||
| to to cell b4 | gb4 |
|
|
||||||
| see all text in cells | aa |
|
|
||||||
| format cells so you can see it. | f |
|
|
||||||
| format wider right | fl |
|
|
||||||
| format smaller left | fh |
|
|
||||||
| format wider down | fj |
|
|
||||||
| format smaller down | fk |
|
|
||||||
|
|
||||||
## Edit
|
# Edit
|
||||||
|
|
||||||
### Text
|
## Text
|
||||||
|
|
||||||
| Action | Key |
|
| Action | Key |
|
||||||
|:----------------------|:---:|
|
|:----------------------|:---:|
|
||||||
@ -49,7 +35,7 @@ echo 'set autowrap' >> .config/sc-im/scimrc
|
|||||||
| text (right align) | > |
|
| text (right align) | > |
|
||||||
| Edit existing text | E |
|
| Edit existing text | E |
|
||||||
|
|
||||||
### Meta Actions
|
## Meta Actions
|
||||||
|
|
||||||
| Action | Key |
|
| Action | Key |
|
||||||
|:----------------------|:---:|
|
|:----------------------|:---:|
|
||||||
@ -62,7 +48,7 @@ echo 'set autowrap' >> .config/sc-im/scimrc
|
|||||||
| delete a cell | x |
|
| delete a cell | x |
|
||||||
|
|
||||||
|
|
||||||
### Functions
|
## Functions
|
||||||
|
|
||||||
| Action | Key |
|
| Action | Key |
|
||||||
|:--------------------------------|:------------:|
|
|:--------------------------------|:------------:|
|
||||||
@ -72,7 +58,7 @@ echo 'set autowrap' >> .config/sc-im/scimrc
|
|||||||
| minimumof those numbers | =@min(B1:B8) |
|
| minimumof those numbers | =@min(B1:B8) |
|
||||||
| multiply C1 to C8 | =@prod(C1:C8)|
|
| multiply C1 to C8 | =@prod(C1:C8)|
|
||||||
|
|
||||||
### Visual
|
## Visual
|
||||||
|
|
||||||
| Action | Key |
|
| Action | Key |
|
||||||
|:--------------------------------|:------------:|
|
|:--------------------------------|:------------:|
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
# This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
|
|
||||||
# You almost certainly shouldn't edit it.
|
|
||||||
|
|
||||||
newsheet "Sheet1"
|
|
||||||
movetosheet "Sheet1"
|
|
||||||
offscr_sc_cols 0
|
|
||||||
offscr_sc_rows 0
|
|
||||||
nb_frozen_rows 1
|
|
||||||
nb_frozen_cols 0
|
|
||||||
nb_frozen_screenrows 2
|
|
||||||
nb_frozen_screencols 0
|
|
||||||
format A 14 1 0
|
|
||||||
format B 18 2 0
|
|
||||||
format 0 2
|
|
||||||
freeze 0
|
|
||||||
label A0 = "Food by Weight"
|
|
||||||
leftstring B0 = "No. Meals"
|
|
||||||
leftstring A1 = "Ajvar"
|
|
||||||
let A1 = 5
|
|
||||||
let B1 = A1*$A$10
|
|
||||||
leftstring A2 = "Apples"
|
|
||||||
let A2 = 3
|
|
||||||
let B2 = A2*$A$10
|
|
||||||
leftstring A3 = "Rocket"
|
|
||||||
let A3 = 0.2
|
|
||||||
let B3 = A3*$A$10
|
|
||||||
leftstring A4 = "Beli Cheese"
|
|
||||||
let A4 = 1
|
|
||||||
let B4 = A4*$A$10
|
|
||||||
leftstring A6 = "Total"
|
|
||||||
let A6 = @sum(A1:A4)
|
|
||||||
leftstring B6 = "Total"
|
|
||||||
let B6 = @sum(B1:B4)
|
|
||||||
leftstring A7 = "Average"
|
|
||||||
let A7 = @avg(A1:A4)
|
|
||||||
leftstring A10 = "Weight of Meal"
|
|
||||||
let A10 = 0.3
|
|
||||||
goto A0
|
|
@ -39,7 +39,7 @@ Try placing this in a file:
|
|||||||
|
|
||||||
> [ One ] { fill: seagreen; color: white; } -- label --> [ Two ] { shape: triangle; }
|
> [ One ] { fill: seagreen; color: white; } -- label --> [ Two ] { shape: triangle; }
|
||||||
>
|
>
|
||||||
> [ One ] => { arrow-style: closed; } [ Three ] { border-style: none; }
|
> [ One ] => { arrow-style: closed; } [ Three ]
|
||||||
>
|
>
|
||||||
> [ Five ] { fill: maroon; color: yellow; } <=> [ Three ]
|
> [ Five ] { fill: maroon; color: yellow; } <=> [ Three ]
|
||||||
>
|
>
|
||||||
@ -54,15 +54,3 @@ Try placing this in a file:
|
|||||||
> [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; }
|
> [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; }
|
||||||
>
|
>
|
||||||
> [ no Network ] --> [ Is there an IP address? ]
|
> [ no Network ] --> [ Is there an IP address? ]
|
||||||
|
|
||||||
> [ Little Group: o]
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
echo "( EU [ Madrid ] <---> [ K ] {label: Karlsruhe;}
|
|
||||||
<== ...O\n ..o\n .O\no \nchoo choo ==> [ Cern ] [ Cern ] <== ...O\n ..o\n .O\no \nchoo choo ==> [ Paris ] <...> [ B ] {label: Budapest} )
|
|
||||||
[ B ] <---> [ Belgrade ] [ G ] {label: Glasgow; }
|
|
||||||
<==> [ M ] {label: Manchester },
|
|
||||||
[ Madrid ] <---> [ Belgrade ] [ M ] <--> [ London ] <--> [ B ],
|
|
||||||
[ Belgrade ]" | graph-easy --boxart
|
|
||||||
```
|
|
||||||
|
@ -13,14 +13,11 @@ The ordering of `/etc/fstab` is
|
|||||||
5. dump
|
5. dump
|
||||||
6. pass
|
6. pass
|
||||||
|
|
||||||
|
E.g.:
|
||||||
|
|
||||||
*Example:*
|
> UUID=877f14e8-4738-46b0-884f-ba330dad1a7d /mnt/biggie ext4 nofail,rw,relatime 0 2
|
||||||
|
>
|
||||||
```
|
> UUID=B21648C416488AF5 /mnt/share ntfs nofail,rw,nosuid,nodev,user_id=0,group_id=0,allow_other,blksize=4096 0 0
|
||||||
UUID=877f14e8-4738-46b0-884f-ba330dad1a7d /mnt/biggie ext4 nofail,rw,relatime 0 2
|
|
||||||
|
|
||||||
UUID=B21648C416488AF5 /mnt/share ntfs nofail,rw,nosuid,nodev,user_id=0,group_id=0,allow_other,blksize=4096 0 0
|
|
||||||
```
|
|
||||||
|
|
||||||
## 5: Dump
|
## 5: Dump
|
||||||
|
|
||||||
|
@ -22,8 +22,3 @@ REP=5
|
|||||||
free --lohi -g -s $REP | lolcat
|
free --lohi -g -s $REP | lolcat
|
||||||
```
|
```
|
||||||
|
|
||||||
Check the next thing cron will do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cronnext /var/spool/cron/$USER -l
|
|
||||||
```
|
|
||||||
|
@ -10,12 +10,6 @@ See a running log of all system messages:
|
|||||||
journalctl -f
|
journalctl -f
|
||||||
```
|
```
|
||||||
|
|
||||||
Or just one user:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
journalctl --user -f
|
|
||||||
```
|
|
||||||
|
|
||||||
Or just one unit (`sshd`):
|
Or just one unit (`sshd`):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user