Top Command Output is not coming via Cronjob


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Top Command Output is not coming via Cronjob
# 1  
Old 12-14-2015
Linux Top Command Output is not coming via Cronjob

Dear All,

I created a small script to get the CPU, GIS usage etc automatically. However when i run this script manually its working , but when i run through cronjob i am not getting any output.

Can anyone please help me on this. I am using SuseLinux.

Thank you in advance.

Code:
#!/bin/sh
{
echo "#############################" >> /var/tmp/TOPUSAGE.csv
echo "" >>  /var/tmp/TOPUSAGE.csv
/bin/date  >> /var/tmp/TOPUSAGE.csv
/usr/bin/top -b -n 1 | egrep -E "Cpu|Mem|Swap|gis" >> /var/tmp/TOPUSAGE.csv
echo "" >>  /var/tmp/TOPUSAGE.csv
echo "#############################"
} >> /var/tmp/TOPUSAGE.csv

# 2  
Old 12-15-2015
post your cron entry.

include the below line your script. for egrep also, use the full path.

Code:
export TERM=xterm

are you redirecting the stdout and stderr of cron ?
# 3  
Old 12-15-2015
Hi,

You haven't included any error messages, however by the sounds of it there are problems with the cron environment.

You'll need to ensure that the environment is correct, the quick and dirty fix is to source your .profile, i.e.
Code:
source ${HOME}/.profile

that way the script will have access to your environmental variable.

You should have had any errors mailed to you, so you can check the mail or error logs.

Regards

Gull04
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unable to scroll to the top of the output of a command

Hello, I am a beginner, I have currently Solaris 11 on a vmware machine. Whenever I type a command like 'ls' the screen scrolls to the end of the screen. I am unable to see the entire list of directories and files. I have tried ls |page command, but looking out for a better option. (3 Replies)
Discussion started by: farheenprasad
3 Replies

2. Ubuntu

Top output to textfile not working in cronjob

Hello, If i run the following script from the cmdline it works just fine however if i run it via root cronjob it doesn't write to the file at all. It is chmod 777 now so shouldnt be any right issues. Shellscript looks like this: /usr/bin/top -b -n 1 -u nagios >> /var/log/test.log Cronjob... (7 Replies)
Discussion started by: heady89
7 Replies

3. Shell Programming and Scripting

Format Top and prstat command output

need help with formatting output of command top and prstat. My requirment is to remove few columns and display remaining . But when i used awk to do that the output seems to be have gone vague, mixing the column values. After using awk to print particular column the output seems to have lost... (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

4. HP-UX

Formatted TOP command output in file

Hi All, I want generate HP-UX overall system performance report. I tried executing top command and write that out put to file. but am not able to view the report in proper format. I can see report like below in file but i can see properly in terminal. Please suggest how can i get... (2 Replies)
Discussion started by: lravip123
2 Replies

5. UNIX for Advanced & Expert Users

Conflicts in the output of TOP command

Hi All, In the output of TOP command in my unix system, i monitored that some process has utilization more than 100% even some process has 4000% utilisation. Please help me understand how it is possible to show more than 100% utilization. Please see the screenshot below:... (2 Replies)
Discussion started by: anand2308
2 Replies

6. Shell Programming and Scripting

Capturing first output from 'top'-likes command

Is this a stupid code?? top > top.out & sleep 2 kill %1 cat top.out Thanks, (6 Replies)
Discussion started by: Shawn, Lee
6 Replies

7. HP-UX

Sorting top command output in HP_UX 11.11

Hello all, I've been woking on Solaris and Linux (Red Hat) so far but now I've inherited an HP-UX system and having minor issues with syntax...Appreciate if you could help me out here.. 1) I'm trying to sort the output of the top command in HP-UX 11.11 by pressing O (capital O) after typing... (2 Replies)
Discussion started by: luft
2 Replies

8. Shell Programming and Scripting

Need help with shell script - output of top command

I have written shell script to send file as an attachemt of email and output of "top -o res" command as email body. it works fine if i execute manually from prompt but it does not send "top -o res" command output in email body when it is executed via crontab. Any suggestions. My script is below:... (5 Replies)
Discussion started by: needyourhelp10
5 Replies

9. Shell Programming and Scripting

Extract header from top command output

hi, I want to extract and save the cpu(s) information from top command output, but individual cpu statistics separately on a multi-processor machine. In command line, top will show this statistics when we press the switch "1". any ideas? thanks, meharo (3 Replies)
Discussion started by: meharo
3 Replies

10. Solaris

Monitoring the output of 'top' command on hourly basis.

I need to capture the following data on an hourly basis through cronjob scheduling:- 1. load averages 2. Total no. of processes. 3. CPU state 4. Memory 5. Top 3 process details. All the above information is available through the command 'top'. But here we need to automate the same and... (4 Replies)
Discussion started by: subharai
4 Replies
Login or Register to Ask a Question