Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My below cronjob is not working. What am I doing wrong here??

*/5 * * * * /usr/bin/top -n1 | head -10 >>/tmp/load.txt
share|improve this question
    
*/5 * * * * /usr/bin/top -n1 | head -10 >>/tmp/load.txt –  user28104 Mar 14 '13 at 7:27
    
Anything in the logs? –  manatwork Mar 14 '13 at 7:29
    
Nothing its blank :( –  user28104 Mar 14 '13 at 7:31
    
Sure that crond is running? –  Hauke Laging Mar 14 '13 at 7:38
    
Tried to specify full path to head too? */5 * * * * /usr/bin/top -n1 | /usr/bin/head -10 >>/tmp/load.txt –  manatwork Mar 14 '13 at 7:38
show 2 more comments

1 Answer

up vote 3 down vote accepted

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

Or:

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
share|improve this answer
    
Good One !!!! gr8 Stephane !!! you rock !!! Thanks for the help !!! –  user28104 Mar 14 '13 at 8:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.