From 44ab1318eea6eae47fec3a09108ae77cfe9521d5 Mon Sep 17 00:00:00 2001 From: sh <37271604+shumvgolove@users.noreply.github.com> Date: Thu, 17 Mar 2022 11:47:33 +0300 Subject: [PATCH] docs(readme): add shell script for cleaning files (#20) --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d2f1182..71a9a22 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,15 @@ $ curl -F "oneshot=@x.txt" "" ``` #### 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