From 1267b498eab114e4ad126ac577e988d34a26d362 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Mon, 22 Jun 2026 17:24:20 +0000 Subject: [PATCH] progress --- examples/crontab.txt | 17 +++++++++++++++++ free_cache.sh | 22 +++++++++++++++++++++- fs_trim.sh | 11 ++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 examples/crontab.txt diff --git a/examples/crontab.txt b/examples/crontab.txt new file mode 100644 index 0000000..178d277 --- /dev/null +++ b/examples/crontab.txt @@ -0,0 +1,17 @@ +# ROOT only crontab +#=========================================================================== +# +# ---------- memory +*/5 * * * * /works/admin/free_cache.sh 2>&1 | /usr/bin/ts '[\%Y-\%m-\%d \%H:\%M:\%S]' >> /works/logs/$(date +\%Y\%m\%d).free_cache.log 2>&1 +# ---------- file system +0 8 * * * /works/admin/fs_trim.sh 2>&1 | /usr/bin/ts '[\%Y-\%m-\%d \%H:\%M:\%S]' >> /works/logs/$(date +\%Y\%m\%d).fstrim.log 2>&1 +# ---------- for logs maintenance +*/30 * * * * chown -R oleg:oleg /works 2>&1 +# +#=========================================================================== +# -------- T e s t +# +# +# -------- T e s t +#=========================================================================== + diff --git a/free_cache.sh b/free_cache.sh index 2a3b9d1..f78b9f8 100755 --- a/free_cache.sh +++ b/free_cache.sh @@ -5,4 +5,24 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi -free -h ; sudo sync; for v in 1 2 3 1 ; do echo ${v} | sudo tee /proc/sys/vm/drop_caches; done; free -h +echo "---------------------------" +echo "Running: ${0} ${*}" +echo +echo "free -h ; sync; for v in 1 2 3 1 ; do echo ${v} | tee /proc/sys/vm/drop_caches; done; free -h" + +free -h +sync +for v in 1 2 3 1 ; do + echo ${v} | tee /proc/sys/vm/drop_caches +done +free -h + +Cmd="/usr/sbin/swapoff -av" +echo ${Cmd} && ${Cmd} + +Cmd="/usr/sbin/swapon -av" +echo ${Cmd} && ${Cmd} + +echo "---------------------------" +echo "DONE: ${0} ${*}" +echo diff --git a/fs_trim.sh b/fs_trim.sh index 1c4273b..bdcccd2 100755 --- a/fs_trim.sh +++ b/fs_trim.sh @@ -5,4 +5,13 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi -/usr/sbin/fstrim -av +echo "---------------------------" +echo "Running: ${0} ${*}" +echo + +Cmd="/usr/sbin/fstrim -av" +echo "${Cmd}" && ${Cmd} + +echo "---------------------------" +echo "DONE: ${0} ${*}" +echo