-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup.sh
More file actions
executable file
·41 lines (33 loc) · 1.36 KB
/
Copy pathcleanup.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
logger "CLEANUP: Clean-up Script Executed"
# ----------------------------------------------------------------
# The below snippet truncates the karma log if over set threshold.
# TMPFS is about 12M. For larger Karma logs consider USB storage.
# ----------------------------------------------------------------
# q = threshold in bytes
q=5242880
w=`ls -la /tmp/karma.log | awk '{print $5}'`
if [ $w -ge $q ]; then
logger "CLEANUP: Karma log over threshold, truncating"
echo "KARMA: Log truncated to prevent memory loss by cleanup.sh" > /tmp/karma.log
# ------------------------------------------------
# Consider moving log to mass storage if available
# ------------------------------------------------
else
logger "CLEANUP: Karma log looking good"
fi
# ------------------------------------------------------------------------
# The below snippet will drop caches if memory is critical.
# Under normal circumstances this shouldn't be an issue but if it ever is,
# this should free up enough memory to keep the device from cycling.
# ------------------------------------------------------------------------
# t = threshold in bytes
t=2048
g=`free | grep Mem | awk '{print $4}'`
if [ $g -ge $t ]; then
logger "CLEANUP: memory looking good"
else
logger "CLEANUP: memory below threshold, dropping pagecache, dentries and inodes"
sync
echo 3 > /proc/sys/vm/drop_caches
fi