I'm calling the Linux top -n 1 -b command from a Qt application to get the free CPU percentage. This application calls this command every 3 seconds, but the CPU usage seems to be updated only the first time the command is invoked in the application and then save this value in cache (only the CPU usage, all others values are updated with every call). If I manually test the top -n 2 -b command on console the realtime CPU is updated only after the second iteration. I can't wait for the second iteration in my application to update the CPU value so I was wondering if there is some system variable or cache that can be modified to get this value update on the first iteration.
Linux top -n 1 Command doesn't get update
linux;top;cache;cpu usage