add rotate.sh

This commit is contained in:
Chris Elsworth 2020-02-28 19:18:49 +00:00
parent 785ed51e32
commit 7f477178b3
3 changed files with 16 additions and 0 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ cheap_slot_data.json
solcast_data.json
vendor/*
Gemfile.lock
logs/*

View File

@ -91,6 +91,13 @@ There's also a wrapper script, `octolux.sh`, which will divert output to a logfi
0,30 * * * * /home/pi/octolux/octolux.sh
```
To complement the wrapper script, there's a log rotation script which you can use like this:
```
59 23 * * * /home/pi/octolux/rotate.sh
```
This will move the current `octolux.log` into `logs/octolux.YYYYMMDD.log` at 23:59 each night.
## Development Notes

8
rotate.sh Executable file
View File

@ -0,0 +1,8 @@
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
mkdir -p $DIR/logs
DATE=`date +%Y%m%d`
mv $DIR/octolux.log $DIR/logs/octolux.$DATE.log