The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Strange error on mpack from cronjob sentinel Shell Programming and Scripting 5 09-21-2008 10:46 AM
cronjob to run perl script AirWalker83 UNIX for Dummies Questions & Answers 6 08-08-2008 03:53 AM
How to call a shellhaving sql script from cronjob azum Shell Programming and Scripting 3 07-10-2008 09:22 AM
cronjob inside the script namishtiwari Shell Programming and Scripting 3 02-04-2008 08:35 AM
help help cronjob problem with script bucci Shell Programming and Scripting 4 02-10-2007 04:38 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-06-2008
sundar63 sundar63 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 32
cronjob: Partial script error

Part of my script throws an error.

Your "cron" job on mitv-t-voms02
/usr/tlrscr/runhc.sh
produced the following output:
/usr/tlrscr/runhc.sh[15]: top: not found
/usr/tlrscr/runhc.sh[17]: top: not found
/usr/tlrscr/runhc.sh[18]: top: not found
syntax error on line 1, teletype

That part of script is :

echo >> /usr/tlrscr/healthchk
top -n 0 | grep -i memory >> /usr/tlrscr/healthchk
echo >> /usr/tlrscr/healthchk
totalmem=`top -n 0 | grep -i memory | awk '{print $2}' | sed 's/M//g'`
free=`top -n 0 | grep -i memory | awk '{print $5}' | sed 's/M//g'`
used=`echo "(($totalmem - $free)/$totalmem) * 100"| bc -l | sed -e "s/\(\.[0-9]\).*/\1/g"`
echo "Physical memory usage is "$used% >> /usr/tlrscr/healthchk
echo >> /usr/tlrscr/healthchk

The script doesn't throw that error when executed manually.
It only happens when it is run by cron at scheduled time.
The "top" is available and can be excuted from command line.

Anyone can help me? Why that part of script fails when run by cron?
  #2 (permalink)  
Old 11-06-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,300
Try to use top with the the full path.

Regards
  #3 (permalink)  
Old 11-07-2008
sundar63 sundar63 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 32
It works!

Thanks a lot, it works.
Hemm, how silly of me not trying with the full path?

Thanks again.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0