Operating System - HP-UX
1819836 Members
2721 Online
109607 Solutions
New Discussion юеВ

Re: Cron error about unknown terminal

 
ankurp
Frequent Advisor

Cron error about unknown terminal

HI ,
pls help resolve this issue.

Sorry, I need to know a more specific terminal type than 'unknown'.

Rgds
Ankur
12 REPLIES 12
Gopi Sekar
Honored Contributor

Re: Cron error about unknown terminal


where exactly you are getting this error message? Is it in the email or in the output of cron ?

try adding 'export TERM=vt100' (basic and known to work on all machines) in your program and see whether that solves the problem.

you can also add this in crontab line.

eg:
1 * * * * export TERM=vt100; /path/to/program

Regards,
Gopi
Never Never Never Giveup
Henk Geurts
Esteemed Contributor

Re: Cron error about unknown terminal

hi ankurp

what is the cron error exactly and what cronentry is it coming from ?

i don't really understand your question.
Do you need to know some terminal types?
vt100 ,vt220 , hp

hope this helps.
regards
Bill Hassell
Honored Contributor

Re: Cron error about unknown terminal

Your cron job is either running as another user by logging in using su - some_user, or you have a command or script that requires a terminal and keyboard. Normally, cron never logs in, but with su -, /etc/profile and then $HOME/some_user/.profile is run and one (or both) of these profiles contains terminal-only commands such as:

tabs
ttytype
tset
tput
clear

cron has no terminal and therefore the interactive terminal commands will report either: "not a typewriter" or "need to know a more specific terminal". It's also possible that you have a command that cannot run in batch mode, that is, it requires an interactive terminal.

In the first case (/etc/profile or .profile), you must protect the terminal-only commands by testing to see if the current environment has a real terminal attached. If not, bypass the command, something like this:

tty -s && tabs
tty -s && clear
tty -s && eval $(ttytype -s)
...etc...

Do this test for each interactive terminal command in the profiles. If you are scheduling an interactive program such as vi or an application program that requires keyboard input, this can't be done in cron because there is no terminal.


Bill Hassell, sysadmin
ankurp
Frequent Advisor

Re: Cron error about unknown terminal

thanks everybody.But i still get that error by mail.
Actually i m writin a scritp that will tell me what caused a peak cpu or memeory utilisation.
Can anyone share a script that will do it for me.
waitin for all ur replies.

rgds
Ankur
Ermin Borovac
Honored Contributor

Re: Cron error about unknown terminal

What command are you running in your cron job? If it's 'top' try running it with -f option. This will redirect its output to a file and it won't complain about the terminal type.
ankurp
Frequent Advisor

Re: Cron error about unknown terminal

hi ,
this is the script. though incomplete.
How can i check top memory hoggin process.

set +x

DT=`date +%d%m%Y`
LFILE=Topps-$DT.log
echo "#################################################### \n " >> $LFILE
#/usr/bin/top -d1 >> $LFILE
date >> $LFILE

UNIX95= /usr/bin/ps -eo sid,pid,ppid,ruser,user,vsz,pcpu,state,args | sort -rn -k 7,7 | head >> $LFILE

/usr/bin/find /usr/scripts/ps_logs -atime -1 -name "Topps*.log" >> $LFILE
echo "\n\n#################################################### \n \n \n " >> $LFILE

thanks

Rgds
Ankur
Ermin Borovac
Honored Contributor

Re: Cron error about unknown terminal

ps line will do but you are sorting on the wrong field (7 instead of 6).

Change the following line

UNIX95= /usr/bin/ps -eo sid,pid,ppid,ruser,user,vsz,pcpu,state,args | sort -rn -k 7,7 | head >> $LFILE

to

UNIX95= /usr/bin/ps -eo sid,pid,ppid,ruser,user,vsz,pcpu,state,args | sort -rn -k 6 | head >> $LFILE

Bill Hassell
Honored Contributor

Re: Cron error about unknown terminal

> thanks everybody.But i still get that error by mail.

The script you posted can't generate the error. Is this script run by another script? Or does the cron job perform an su? The issue is with commands run outside of your script. You can trace the script with: set -x, however, you'll need to add set -x to /etc/profile and .profile to find the error message's location.


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: Cron error about unknown terminal

If you set TERM and aforementioned variable the script above will not continue to produce the error.

The error you have has three possible causes.

All of them are the environment.

Bet the script runs fine from the command line.

env > /tmp/regular.env.txt

In the script add:

env > /tmp/cron.env.txt

run via cron

cd /tmp

diff cron.env.txt regular.env.txt

The answer lies here.

:-)

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
ankurp
Frequent Advisor

Re: Cron error about unknown terminal

no luck still,
Ya the env variables are different.

# diff cron.env.txt regular.env.txt
1a2,4
> MANPATH=/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man:/opt/mx/share/man:/opt/upgrade/share/man/%L:/opt/upgrade/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/resmon/share/man:/opt/hparray/share/man/%L:/opt/hparray/share/man:/opt/graphics/common/man:/usr/dt/share/man:/opt/samba/man:/opt/gnome/man:/opt/ignite/share/man/%L:/opt/ignite/share/man:/opt/wbem/share/man:/opt/omni/lib/man:/opt/perf/man/%L:/opt/perf/man:/opt/ssh/share/man:/opt/iexpress/tcpdump/man:/opt/iexpress/openldap/man:/opt/iexpress/sudo/man
> SHLIB_PATH=/u01_local/app/oracle/product/8.1.7/lib
> SSH_TTY=/dev/pts/2
2a6,8
> COLUMNS=142
> EDITOR=vi
> HISTFILE=/.sh_history
3a10,12
> MAIL=/var/mail/root
> ERASE
> USER=root
5a15,19
> SSH_CONNECTION=WWW.XX.XXX.XX 44029 XXX.XXX.XX.X4 22
> SSH_CLIENT=XX.WW.WW.140 44029 22
> LD_LIBRARY_PATH=/u01_local/app/oracle/product/8.1.7/lib
> TERM=xterm
> ORACLE_HOME=/u01_local/app/oracle/product/8.1.7
7a22
> LINES=51

This just a simple script cant understand why it is not working.

CRONTAB -l

0,15,30,45 * * * * /usr/scripts/ps_logs/top_ps.sh.1 > /usr/scripts/ps_logs/top_ps.sh.log

waitn.

rgds
Ankur
Bill Hassell
Honored Contributor

Re: Cron error about unknown terminal

Can you post the output of this:

sh -x /usr/scripts/ps_logs/top_ps.sh.1

Your script is running a terminal command or program that is calling the Curses library. In the /usr/lib directory, the following string:

"Sorry, I need to know a more specific terminal type than '%s'."

exists in: libHcurses.a libHcurses.sl libcurses.0 libcurses.1

so this is the source of the error message. However, the actual command in your script (including su to a user, etc) will have to be traced as shown abaove. The set -x stays in force only for the current script. You will need to locate any sourced scripts or user switches and trace profiles.


Bill Hassell, sysadmin
ankurp
Frequent Advisor

Re: Cron error about unknown terminal

thanks , this is the script.
Would appreciate if anyone can change this script for good.

DT=`date +%d%m%Y`
LFILE=Topps-$DT.log
echo "#################################################### \n " >> $LFILE
#/usr/bin/top -d1 >> $LFILE
date >> $LFILE

UNIX95= /usr/bin/ps -eo sid,pid,ppid,ruser,user,vsz,pcpu,state,args | sort -rn -k 7,7 | head >> $LFILE

/usr/bin/find /usr/scripts/ps_logs -atime -1 -name "Topps*.log" >> $LFILE
echo "\n\n#################################################### \n \n \n " >> $LFILE

UNIX95= /usr/bin/ps -eo sid,pid,ppid,ruser,user,vsz,pcpu,state,args | sort -rn -k 6 | head >> $LFILE

waitn for replies friends.

rgds
Ankur