LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   script not running in cronjob (https://www.linuxquestions.org/questions/solaris-opensolaris-20/script-not-running-in-cronjob-662648/)

dningale 08-13-2008 10:59 PM

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.

Ken-ji 08-14-2008 12:27 AM

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

garyalex 08-14-2008 12:27 AM

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?


All times are GMT -5. The time now is 10:58 PM.