Browse Source

Create eat.service

MoeClub 2 years ago
parent
commit
ee3049170b
1 changed files with 13 additions and 0 deletions
  1. 13 0
      Oracle/eat.service

+ 13 - 0
Oracle/eat.service

@@ -0,0 +1,13 @@
+[Unit]
+Description=MemoryEat
+After=dbus.service
+
+[Service]
+Type=simple
+ExecStart=/bin/sh -c 'while true; do /usr/bin/free |/usr/bin/grep "^Mem:" |/usr/bin/sed "s/[[:space:]]\+/ /g" | { read t T U F S B A; P=$([ -f /run/shm/MemoryEat.bin ] && /usr/bin/du --apparent-size --block-size=1000 /run/shm/MemoryEat.bin |/usr/bin/cut -f1 || /usr/bin/echo 0); C=$(($(($T * 10 / 100)) - $(($T - $A)) + $P)); [ $C -le 0 ] && /usr/bin/echo 0 || /usr/bin/echo $C; } |/usr/bin/xargs -I {} /usr/bin/dd if=/dev/zero of=/run/shm/MemoryEat.bin bs=1kB count={} >/dev/null 2>&1; [ -f /run/shm/MemoryEat.bin ] && /usr/bin/sleep 15 || break; done'
+ExecStop=/bin/sh -c '/usr/bin/rm -rf /run/shm/MemoryEat.bin'
+RestartSec=3s
+Restart=always
+
+[Install]
+WantedBy=multi-user.target