In my CentOS, i'm trying to print the CPU USAGE and FREE MEMORY output numbers into a text file. But when i typing in the terminal, it is all fine. But when it is executed via the crontab the MEMORY output is always blank.Manually typing in terminal:# echo CPU: `top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}'`, RAM: `awk '/^Mem/ {print $4}' <(free -m)` >> ~/stats.txt# cat ~/stats.txtCPU: 3.8, RAM: 1307Same command in Crontab:*/10 * * * * echo CPU: `top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}'`, RAM: `awk '/^Mem/ {print $4}' <(free -m)` >> ~/stats.txtThen inside the Text file:# cat ~/stats.txtCPU: 3.4, RAM: CPU: 4.1, RAM: CPU: 3.9, RAM: Why is the RAM output always blank please?
Shell Script (in Crontab) : Saving Memory print into text file always gives blank
shell script;cron;memory
Because dash doesn't understand this kind of bashism:<(free -m)Instead, use:free -m | awk '/^Mem/ {print $4}'