Article 6GKK3 Why is the memory usage sharply decreased after restarting the service?

Why is the memory usage sharply decreased after restarting the service?

by
Matthew Wai
from LinuxQuestions.org on (#6GKK3)
Code:Matthew_Wai@My-PC:~$ systemd-cgtop -m|grep "HDD_temp.service"|tr -s " "
/system.slice/HDD_temp.service 2 - 249.0M - -
Matthew_Wai@My-PC:~$ sudo systemctl stop HDD_temp.service && sudo systemctl start HDD_temp.service
[sudo] password for Matthew_Wai:
Verification successful
Matthew_Wai@My-PC:~$ systemd-cgtop -m|grep "HDD_temp.service"|tr -s " "
/system.slice/HDD_temp.service 2 - 480.0K - -
Matthew_Wai@My-PC:~$The above output shows the following:
(1) "HDD_temp.service" used 249 MB of memory originally.
(2) "HDD_temp.service" was restarted.
(3) "HDD_temp.service" used 480 KB of memory after the restart.

Does anyone know why the memory usage dropped sharply after restarting the service, which worked properly as usual after the restart?
The following is the content of "HDD_temp.service".
Code:[Service]
ExecStart=/@/Fancontrol/HDD_temp.sh

[Install]
WantedBy=multi-user.targetThe following is the content of "HDD_temp.sh".
Code:#!/bin/bash
while [ -z "${S}" ];do sleep 10s;for ((N=0;N<20;N++));do
service fancontrol status|grep running && S="OK" && N=20
if [ -z "${S}" ];then sudo service fancontrol start;fi;done;done

File=/@/Fancontrol/Log ; if [ "${S}" == "OK" ] ; then
echo $(date) Success>>"${File}";else
echo $(date) Failure>>"${File}";exit;fi;unset S N File

while : ; do T=$(sudo hddtemp -n /dev/sda)
echo $((${T} * 1000)) > "/@/Fancontrol/Hddtemp"
sleep 30 ; done
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments