Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a problem executing a cron process to check current CPU use in my server.

My script start with:

top -c -n 1 -u www-data > /tmp/kill-cpu

I can execute without problem in console, but in cron I get

top: failed tty get

If I use the -b option to top

top -b -n 1

I get

'dumb': unknown terminal type.

I'm using xterm as TERM

Thanks for your help :)
Lito.

SOLUTION: I was able to solve the problem with:

ln -s /lib/terminfo/d/dumb /usr/share/terminfo/d/dumb
share|improve this question

1 Answer 1

You can try something like:

TERM=vt100 top -b -n 1

This will set the TERM variable to execute with the "top" command.

But your underlying problem is that your termcap database is incomplete or broken. I don't have a Debian machine to look at, but on an Ubuntu box, the "dumb" termcap info is in the file /usr/share/terminfo/d/dumb. This file is part of the ncurses-base package on Ubuntu 8.04 and 10.04. On RHEL, it's part of the ncurses package. Perhaps your installation is simply missing this file?

share|improve this answer
    
Yep, I was just digging around in the top source and if you choose batch mode it sets TERM to dumb. –  Iain Aug 24 '11 at 13:56
    
No, problem is not solved with this command: root@server:~# TERM=vt100 top -b -n 1 'dumb': unknown terminal type. root@server:~# ls /usr/share/terminfo/d/dumb ls: /usr/share/terminfo/d/dumb: No such file or directory I have 286 files in /usr/share/terminfo/d/ folder –  Lito Aug 24 '11 at 14:09
    
OK, you'll have to figure out why the /usr/share/terminfo/d/dumb file is missing from that system. As noted, I don't have a Debian box to play with. On Ubuntu, the package that provides that file is "ncurses-base". Perhaps you can do "apt-cache search dumb" to figure out which package you'll need on Debian. I suppose you can also copy the file from your working Debian box, but it'd be better to figure out if a package is missing or broken. –  cjc Aug 24 '11 at 14:32
    
Yes, apt-cache search dumb | grep term = ncurses-base but installing/reinstalling the package don't solve my problem. In my other (development) Debian 6 server (same version as production) I can execute "top -b" without problems and I haven't this dumb term file... –  Lito Aug 24 '11 at 14:51
    
Run something like "strace top -b -n 1 2>&1 |grep term". This will show you the terminfo files that the "top" command is accessing. Do this on the box everything is working on, and the box that it's not working on. I just ran it on a RHEL box, and it looks for terminfo first in ~/.terminfo/d/dumb. Possibly, the user executing the cron on the other box has that file. If not, "strace" will show what the "top" command is actually doing. –  cjc Aug 24 '11 at 16:55

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.