LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 08-13-2008, 11:59 PM   #1
dningale
LQ Newbie
 
Registered: Aug 2008
Posts: 25

Rep: Reputation: 15
script not running in cronjob


set zar=0
set tot=0
for tot in 0
do
while read i
do
cd /opt/audible/logs/cdl/$i
d=`date|cut -d' ' -f1,2,3`
e=`date|cut -d' ' -f4|cut -d':' -f1`
f="$d $e:00"
zar=`cat aws_dynamic_partial.log |grep "${f}"|cut -d' ' -f14 | tr -s ',' ' '`
tot=`expr $tot + $zar`
echo $tot > /home/dingale/file
done
done < serverlist.txt
echo no of c programms running are $tot|mailx -s "No of c programmes running are $tot" dingale@domain.com



This script runs fine when fired manually
but gives blank value when run as cronjob.

Thanks,
Ingale D. N.
 
Old 08-14-2008, 01:27 AM   #2
Ken-ji
LQ Newbie
 
Registered: Apr 2003
Location: Philippines
Distribution: Slackware
Posts: 19

Rep: Reputation: 0
You're not specifying the all important magic header in scripts that tell your shell what interpreter will be running the script.

In this case, your script seems to be a sh/bash like script so you need to insert the following to very 1st line:
Code:
#!/bin/sh
 
Old 08-14-2008, 01:27 AM   #3
garyalex
Member
 
Registered: Jun 2006
Location: Johannesburg, South Africa
Distribution: Ubuntu, CentOS, Debian
Posts: 47

Rep: Reputation: 15
When run as a cronjob you need to ensure the paths are found in your script. The safest way to do this is to always specify the full path for each utility (eg /bin/grep instead of just grep)

Try this in your script and see if it helps?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script expression not running in cronjob dningale Solaris / OpenSolaris 2 08-13-2008 01:04 AM
sftp script via cronjob ?? OzTEXS Linux - Security 21 12-28-2006 04:38 PM
Cronjob / script question nazs Linux - General 1 12-21-2006 02:45 PM
cronjob php script MrSako Linux - General 1 08-27-2006 08:30 PM
cronjob not working but script works dtra Linux - Newbie 4 02-28-2005 06:05 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration