To view the buff/cache:
free -h

To clean the buff/cache:
echo 1 > /proc/sys/vm/drop_cachesecho 2 > /proc/sys/vm/drop_cachessync && echo 3 > /proc/sys/vm/drop_caches
You can put these shell commands in a script and run it in schedule with crontab:
Firstly, create script named clean.sh.
#!/bin/bashecho 1 > /proc/sys/vm/drop_cachesecho 2 > /proc/sys/vm/drop_cachessync && echo 3 > /proc/sys/vm/drop_caches
Secondly, run the script with crontab.
# Run commands go into editor mode.crontab -e# Enter editor mode and input below content with vim command.# Execute once every 4 hours.0 */2 * * * sh /your/path/clean.sh# View the script if it exists or not.crontab -l# Clean the script if exist.crontab -r