I want to get the CPU percentage measured every minute and written to a file. The command is as follow: Code: Select all
* * * * * cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS='' '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' > /log/mainboard_cpu.log
If I run the code manually, I get the CPU written to the file but the cronjob doesn't do anything. Is there another way to execute the command and write it to a file? Thank you.
I am running the code on the Raspberry Pi.