#write in userinit.sh
#use cgroup tuning cpu tasks, default init.rc can't write
busybox mkdir -p /dev/cgroup/cpu
busybox mount -t cgroup cgroup -o cpu /dev/cgroup/cpu
echo "/system/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent
busybox mkdir -m 0777 /dev/cgroup/cpu/bg_root
chown root.root /dev/cgroup/cpu/bg_root/tasks
chmod 0777 /dev/cgroup/cpu/bg_root/tasks
echo "500" > /dev/cgroup/cpu/bg_root/cpu.shares #root can get 50% cpu time?
busybox mkdir -m 0777 /dev/cgroup/cpu/bg_non_interactive
chown system.system /dev/cgroup/cpu/bg_non_interactive/tasks
chmod 0777 /dev/cgroup/cpu/bg_non_interactive/tasks
echo "200" > /dev/cgroup/cpu/bg_non_interactive/cpu.shares #system can get 20% cpu time ?
echo "1" > /dev/cgroup/cpu/notify_on_release
echo "1" > /dev/cgroup/cpu/bg_root/notify_on_release
echo "1" > /dev/cgroup/cpu/bg_non_interactive/notify_on_release
nice logcat > /system/sd/swap/$(date +%Y%m%d-%H).log & #save log
nice /data/local/Clear.sh &
nice /data/local/SCgroupTask.sh & //60s update tasks
#Clear.sh
#!/system/bin/sh
while [ true ]
do
echo 'start'
for file in `find /system/sd/logs -mtime +3 -name '*.log' -print 2>/dev/null`
do
rm $file
done
sleep 24h
done
#SCgroupTask.sh
-----
while [ true ]
do
ps | grep root | awk '{print $2}' > /dev/cgroup/cpu/bg_root/tasks #add root tasks to cgroup
ps | grep system\ | awk '{print $2}' > /dev/cgroup/cpu/bg_non_interactive/tasks #add system tasks to cgroup
sleep 60s
done
JUST FOR FUN!!
沒有留言:
張貼留言