Small systemd timer/service to drop Linux page cache when RAM usage crosses a configurable threshold.
- Checks
MemTotalandMemAvailablefrom/proc/meminfo - Computes used RAM percentage
- Runs
syncandecho 3 > /proc/sys/vm/drop_cacheswhen the threshold is reached - Applies a cooldown to avoid running too often
This is useful if you want to keep a repeatable copy of the setup outside /etc and /usr/local/bin, so you can reinstall it after a fresh OS install.
bin/kentut: main commandsystemd/kentut.service: oneshot servicesystemd/kentut.timer: periodic timersystemd/kentut.env: editable configurationinstall.sh: install files into system locationsuninstall.sh: remove installed files
- Threshold:
70% - Cooldown:
900seconds - First run:
2minutes after boot - Interval: every
1minute
cd ~/Downloads/kentut
sudo ./install.shAfter install, you can run:
kentut
kentut -t 5m
kentut -t 5s
kentut -t 5h -m 50%
kentut -m 50
kentut --status
kentut --watch 30s --dry-run
sudo kentut --set-threshold 55
sudo kentut --enable
sudo kentut --disable
sudo kentut --forceEdit:
sudo nano /etc/default/kentutAvailable variables:
THRESHOLD_PCT=70COOLDOWN_SECONDS=900STATE_FILE=/run/kentut.last
kentut: run immediately using current thresholdkentut -t 5m: wait 5 minutes, then run the checkkentut -t 5s: wait 5 seconds, then run the checkkentut -t 5h: wait 5 hours, then run the checkkentut -m 50orkentut -m 50%: use50%as the threshold for that runkentut --force: drop cache without checking thresholdkentut --dry-run: simulate the action without writing todrop_cacheskentut --status: print current RAM usage, threshold, cooldown, and last runkentut --watch 30s: run in a loop every 30 secondskentut --set-threshold 55: persist threshold to/etc/default/kentutkentut --enable: enable and startkentut.timerkentut --disable: disable and stopkentut.timerkentut --start: startkentut.timerkentut --stop: stopkentut.timerkentut --restart: restartkentut.timerkentut --json: return status or update output as JSONkentut --notify: send a desktop notification whennotify-sendis availablekentut -horkentut --help: show English help
Notes:
-monly overrides the threshold for the current command.- The persistent threshold for the systemd service still comes from
/etc/default/kentut. - Dropping page cache still requires root because it writes to
/proc/sys/vm/drop_caches. - Running
kentutwithout root can do the countdown and memory check, but if the threshold is hit it will stop and tell you to usesudoor the system service. --set-thresholdalso requires root because it edits/etc/default/kentut.--enable,--disable,--start,--stop, and--restartalso require root because they callsystemctlon the system timer.
Then reload and restart the timer:
sudo systemctl daemon-reload
sudo systemctl restart kentut.timersystemctl status kentut.timer
systemctl status kentut.service
journalctl -u kentut.service --no-pagercd ~/Downloads/kentut
sudo ./uninstall.sh