1826654 Members
1782 Online
109695 Solutions
New Discussion

used the top with cron

 
SOLVED
Go to solution
Isaac_4
Frequent Advisor

used the top with cron

I try to put the top in the cron, the error that I recived in mail root is.


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

The time is gold
5 REPLIES 5
Robert Gamble
Respected Contributor
Solution

Re: used the top with cron

You probably need to modify the shell script you are running in the cron.

try:
#!/bin/sh
TERM=vt100 ; export TERM
top -f > /foo/top.out
Michael Tully
Honored Contributor

Re: used the top with cron

Top is supposed to run to a tty. It would better if you were trying to collect system performance information to use the measure agent of glance or the output of sar. There are many posts on this.
Anyone for a Mutiny ?
Patrick Wallek
Honored Contributor

Re: used the top with cron

If you are using top in a cron job, you probably want to specify the '-f filename' option as well so that output gets written to a file.

Something like:

top -d 5 -n 30 -f /tmp/filename

will run through 5 iterations of top with the top 30 processes of each iteration.
Robert Gamble
Respected Contributor

Re: used the top with cron

oops!

There should not be a redirect in my previous post.

top -f /foo/top.out

That will should work.
A. Clay Stephenson
Acclaimed Contributor

Re: used the top with cron

Actually, there is a way. Inside your cron script, do a top -f /var/tmp/tfile and then mail your tempfile.

You should of course, create a temp file name, mail it, and then remove the temp file but top -f filename is the key. Top will run once and exit.
If it ain't broke, I can fix that.