I am working on one project required to monitor the UPS using NUT server. For monitoring and data logging I am using the minibian OS (JESSIE). In order to monitor the ETON UPS I have wrote a shell script which inquires data every second.  As I am using one 8Gb sd card to store OS and data log, I have partitioned it as root(2Gb) and datalog(4Gb) drives. The UPS monitor script is launched by Crontab as a background process. The feature included in UPS Monitor scripts are as follows:Fetch UPS data every 1 SecondGenerate new folder every day Time stamp the log files .csvSearch for folder older than 1 day, compress it and delete folderIssue:I assumed that the 2 GB space for root would be enough as my OS only takes around 800 Mb. But as I run a test for three days the root partition has consumed more than 100 Mb in three days. In this case, my root partition will be filled within 30 days   I am not sure why running shell script causing too much overhead in memory. Here is the memory usage by Raspberry Pi OS (without shell script) and UPS Monitor (with shell scripts)Test Run Time: 3 DaysUPS Monitor Memory Test: START UPS Monitor Memory Test: STOPRaspberry PI OS Memory Test: START Raspberry PI OS Memory Test: STOP Memory Usage of ScriptsI have found some links online to find the memory usage by script, But not able to make any sense out of it. Data Logging Script#!/bin/bashgpio -g mode 16 outgpio -g mode 21 outgpio -g write 16 0gpio -g mode 24 inLOG_PATH='/media/ntfs/logs/'LOG_HEADER=`date +%H:%M:%S`LOG_DIR_NAME=`date +%d_%m_%Y`LOG_FOLDER=`find /media/ntfs/logs -type d -mtime +0`timeCounter=0switchRead=0#  Browse log directorycd -- $LOG_PATHLOG_NAME=$LOG_HEADERwhile :do    switchRead=`gpio -g read 24`    LOG_DIR_NAME=`date +%d_%m_%Y`    LOG_DIR=$LOG_PATH$LOG_DIR_NAME    echo $LOG_DIR    if [ -d $LOG_DIR ]    then            cd -- $LOG_DIR            echo DIRECTORY FOUND    else        mkdir -p $LOG_DIR        LOG_NAME=`date +%H:%M:%S`        echo NEW DIRECTORY CREATED!!!!!        cd -- $LOG_DIR        HEADER='UPS MODEL, UPS STATUS, BATTERY CHARGE, BATTERY RUNTIME,$        echo $HEADER > $LOG_NAME.csv        # Calling old folder compression script        /root/day.sh    fi    # executing ups status command and saving result in array    declare -A status=($(upsc myups | sed 's/\(.*\):\(.*\)/[\1]=\2/'))    if [[ ${status[device.model]} !=  ]] ; then        echo WRITIN FILE        echo  ${status[device.model]},${status[ups.status]}, ${stat$    fi    if [[ ${status[ups.status]} = *OB* ]] ; then        timeCounter=$(( $timeCounter+1))        #echo $timeCounter  :(        if [[ $timeCounter -gt 20 ]] ; then            #echo :D            timeCounter=0            LOG_NAME=`date +%H:%M:%S`            echo $HEADER > $LOG_NAME.csv       fi    fi    if [[ $switchRead = 1 ]] ; then        echo Read Kar liya bhiya        gpio -g write  16 1        `sudo shutdown -h now`    else        gpio -g write 16 0    fi    gpio -g write 21 0    sleep 0.5    gpio -g write 21 1    sleep 0.5doneexit 0Thank you 
Memory Issue: Raspberry Pi
shell script;raspberry pi;out of memory;ups;nut