cronjob: Partial script error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cronjob: Partial script error
# 1  
Old 11-06-2008
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  
Old 11-06-2008
Try to use top with the the full path.

Regards
# 3  
Old 11-07-2008
It works!

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

Thanks again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to compare partial filenames in two folders and delete duplicates

Background: I use a TV tuner card to capture OTA video files (.mpeg) and then my Plex Media Server automatically optimizes the files (transcodes for better playback) and places them in a new directory. I have another Plex Library pointing to the new location for the optimized .mp4 files. This... (2 Replies)
Discussion started by: shaky
2 Replies

2. UNIX for Beginners Questions & Answers

Scanning array for partial elements in Bash Script

Example of problem: computerhand=(6H 2C JC QS 9D 3H 8H 4D) topcard=6D How do you search ${computerhand} for all elements containing either a "6" or a "D" then save the output to a file? This is a part of a Terminal game of Crazy 8's that I'm attempting to write in Bash. Any... (2 Replies)
Discussion started by: cogiz
2 Replies

3. Shell Programming and Scripting

Partial variable substitution in script

I have a script. filecreatenew () { touch /usr/src/$1_newfile.txt var=$1 echo $var touch /usr/src/$var_newfile_with_var.txt } filecreatenew myfile Its creating file /usr/src/myfile_newfile.txt as the variable $1 is correctly used. When $ is... (2 Replies)
Discussion started by: anil510
2 Replies

4. Shell Programming and Scripting

Error at the time of cronjob run

Hi All , Please read the below data carefully. I have run the below script on unix server its running succesfully. but when i run the same script using cronsetyp it giving me the error : command not found at (line num):cruiseStartup.sh below is code netstat -anp |grep 8181... (5 Replies)
Discussion started by: aish11
5 Replies

5. Shell Programming and Scripting

AWK - Print partial line/partial field

Hello, this is probably a simple request but I've been toying with it for a while. I have a large list of devices and commands that were run with a script, now I have lines such as: a-router-hostname-C#show ver I want to print everything up to (and excluding) the # and everything after it... (3 Replies)
Discussion started by: ippy98
3 Replies

6. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

7. Shell Programming and Scripting

stty error when script is called out of a cronjob

Hello, I'm trying to implement a script to call a third-party tool every so often and write the results to a file. If I run it interactively it works fine, but when it comes to run it out of a cronjob, I keep getting this error: stty: tcgetattr: a specified file does not support the... (3 Replies)
Discussion started by: fabiogilr
3 Replies

8. Shell Programming and Scripting

A running Script giving error while scheduled in cronjob

Hi, I have script which is properly running but when i schedule it in cron it throws an error like : Your "cron" job on retrprdapp1 /usr/bin/sh /retr/cron/ftp.sh 2>&1 produced the following output: /retr/cron/ftp.sh: syntax error at line 17: `(' unexpected line17 is # Get list of... (10 Replies)
Discussion started by: rajagasti
10 Replies

9. Shell Programming and Scripting

shell script to partial delete

guys i need some help in writing a shell script, what i am trying to write is a shell script that can delete generated trace files my software usually generated everyday, i will give an example to make it easy to understand root@cms-db # pwd /pcard17/trace root@cms-db # ls -l HSM_VERIF.TRC*... (4 Replies)
Discussion started by: q8devilish
4 Replies

10. Shell Programming and Scripting

Strange error on mpack from cronjob

I have a shell script which mails a file. It runs fine when executed at prompt, but from cronjob the following line gives an error: $ /opt/local/bin/mpack -s "TTW posts " $FILEPATH/ttw.html myemail@gmail.com Error is : (some junk chars) followed by No such file or directory. Before this... (5 Replies)
Discussion started by: sentinel
5 Replies
Login or Register to Ask a Question