Linux set the timer clear buff / cache script

View state memory cache

[root@heyong ~]# free -m
total used free shared buff/cache available
Mem: 96406 19256 11311 66 65837 76421
Swap: 4095 1016 3079

Clean the cache of scripts

[root@heyong ~]# vim /home/script

#!/bin/bash

# Started clearing the cache
echo "start clearing the cache"

# Written to disk, to prevent loss of data
sync; sync; sync

# 10-second delay
sleep 10

# Clean the cache
echo 3> / proc / sys / vm / drop_caches

Setting regular tasks (clean up once a day at 2:30 am)

[Root @ gonghuikeji ~] # crontab -e

clear buff/cache

30 2 * /home/script/clear_buff_cache.sh

Guess you like

Origin blog.51cto.com/heyong/2426817