Use the free command to test RAM usage.
To check the size of the program in memory, you can check the file /proc/[pid]/statm . Read more about the format of this file man proc
Extract the PID from the script from the script using the $$ variable (in bash).
EDIT
Other solutions:
ps u $PID | tail -n1 | tr -s ' ' | cut -d ' ' -f 5,6 ps u $PID | tail -n1 | tr -s ' ' | cut -d ' ' -f 5,6 Gives you the VMZ and RSS process using $PID .
Or you might want to see only the process memory with
watch -n0.5 ps u $PID
this will update the memory usage for your process every 0.5 seconds. If necessary, adjust the value for the update.
source share