My below cronjob is not working. What am I doing wrong here??
*/5 * * * * /usr/bin/top -n1 | head -10 >>/tmp/load.txt
*/5 * * * * /usr/bin/top -n1 | /usr/bin/head -10 >>/tmp/load.txt
The top from procps on Linux at least needs the $TERM environment variable to know how to display things like reverse color and cursor positioning when not in batch mode
So either run:
top -bn1 | head
TERM=dumb top -n1 | head
Or if you need the output suitable for any given terminal, specify it as
TERM=my-terminal top -n1 | head
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the
terms of service.
2 months ago