Create load logging script
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
live_until.txt
|
live_until.txt
|
||||||
*.swp
|
*.swp
|
||||||
|
logs/*
|
||||||
|
servers
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
||||||
Install systemd services
|
Assuming user is `ubuntu`. Extract in `/home/ubuntu/minecraft`
|
||||||
|
|
||||||
|
# Install systemd services
|
||||||
```
|
```
|
||||||
mkdir -p /home/ubuntu/.config/systemd/user
|
mkdir -p /home/ubuntu/.config/systemd/user
|
||||||
ln -s /home/ubuntu/minecraft/services/set_initial_ttl.service /home/ubuntu/.config/systemd/user/set_initial_ttl.service
|
ln -s /home/ubuntu/minecraft/services/set_initial_ttl.service /home/ubuntu/.config/systemd/user/set_initial_ttl.service
|
||||||
@@ -12,3 +14,9 @@ systemctl --user enable set_initial_ttl
|
|||||||
systemctl --user enable ensure_running
|
systemctl --user enable ensure_running
|
||||||
loginctl show-user ubuntu --property Linger
|
loginctl show-user ubuntu --property Linger
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Setup user linger and crontab
|
||||||
|
```
|
||||||
|
loginctl enable-linger ubuntu
|
||||||
|
crontab -l /home/ubuntu/minecraft/crontab
|
||||||
|
```
|
||||||
|
|||||||
1
crontab
1
crontab
@@ -1 +1,2 @@
|
|||||||
* * * * * /home/ubuntu/minecraft/autoshutdown.sh
|
* * * * * /home/ubuntu/minecraft/autoshutdown.sh
|
||||||
|
* * * * * /home/ubuntu/minecraft/load.sh
|
||||||
|
|||||||
16
load.sh
Executable file
16
load.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export TZ="Europe/Stockholm"
|
||||||
|
|
||||||
|
LOGPATH="/home/ubuntu/minecraft/logs"
|
||||||
|
LOGFILE="$LOGPATH/$(date "+%F").log"
|
||||||
|
|
||||||
|
timestamp() {
|
||||||
|
date "+%R"
|
||||||
|
}
|
||||||
|
|
||||||
|
load() {
|
||||||
|
cat /proc/loadavg | awk '{print $1}'
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "$(timestamp) $(load)" >> $LOGFILE
|
||||||
0
logs/.gitkeep
Normal file
0
logs/.gitkeep
Normal file
Reference in New Issue
Block a user