I am trying to run a python script in my crontab which checks the CPU load of my system and writes the result into an html file. I am calculating the cpu load using the psutil module's cpu_percent() method. When I execute the script in my jupyter notebook it runs perfectly OK. But when I place the script in my crontab as below:-
- /Applications/anaconda/bin/python Html_python.py >Html_python.log 2>&1
The cron job does run and the output gets redirected in the log file but the html file does not show the correct cpu load and only shows 0.0 But after I run the script manually the correct cpu load is again reflected.
I think I am not using the psutil.cpu_percent() method correctly, by specifying the parameters like interval and percpu. Not able to understand how these two parameters work.
Can someone help me to understand these parameters clearly. Thanks in advance.