docs(readme): add shell script for cleaning files (#20)

This commit is contained in:
sh 2022-03-17 11:47:33 +03:00 committed by GitHub
parent d3a9e0c69d
commit 44ab1318ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -100,9 +100,15 @@ $ curl -F "oneshot=@x.txt" "<server_address>"
```
#### Cleaning up expired files
Change `/path/to/rusty` to your rustypaste folder and put this script in the `cron`.
```sh
$ find upload/ -maxdepth 2 -type f -iname "*.[0-9]*" -exec rm -v {} \;
#!/bin/env sh
now=$(date +%s)
find /path/to/rusty/ -maxdepth 2 -type f -iname "*.[0-9]*" |
while read filename; do
[ "$(( ${filename##*.} / 1000 - ${now} ))" -lt 0 ] && rm ${filename}
done
```
#### URL shortening