![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script not running properly when run from Crontab | simoncjones | Shell Programming and Scripting | 2 | 05-03-2009 02:11 PM |
| problem running shell script (for oracle export) in crontab | jsheehan223 | Shell Programming and Scripting | 1 | 10-16-2008 03:29 PM |
| Facing issue in Solaris OS in crontab for running shell script | mabrar | Shell Programming and Scripting | 2 | 11-02-2007 06:32 AM |
| Command Not running in script | Dastard | Shell Programming and Scripting | 2 | 05-21-2007 05:08 PM |
| running multiple rsh command in a script | lweegp | Shell Programming and Scripting | 0 | 10-31-2006 02:37 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
A command in a script not running in Crontab.
Hi,
I made this script for TRU Unix 5.1 OS based Node. When the script was run manually all the commands were running properly. But when it was run from Crontab, one command is not running. This command is not running when the script is running from Crontab: # /usr/mg2/svi/svicom/svistatjo.x -j 20090702 -f stat_log_temp (This is a application based command used ti fetch certain statistics of that application depending on the date) I am using /bin/ksh shell in the script.The crontab I am using is for root user, and the command is also run by root [ Following are the fixes that I have tried till now, but it has not done any good: Fix 1: I tried to find the directory from which the command is executing by the following way: # cd /usr/mg2/svi/svicom # which svistatjo.x Output: /usr/mg2/svi/svicom/svistatjo.x If the command 'which svistatjo.x' is executed from any other path, no ouput is obtained. This is the reason the command i gave above was with the full path. Fix 2: I used the command this way in the script too, but it is still not runnng through crontab. #su -c "svistatjo.x -j 20090702 -f stat_log_temp" Also, Whenever I am running the script from Crontab, an error is coming in mail, something like : "stty: tcgetattr: Not a typewriter stty: tcgetattr: Not a typewriter Not a terminal Ambiguous output redirect. ", but I am not sure how this error is related to the command. ]Please suggest modifications so that this command can be run from crontab also. \\ Thanks in anticipation |
|
||||
|
Thanks for the prompt reply... here is the part of the script(in bold) where the error is occuring.
In crontab entry i have simply given entry like this: 00 2 * * * /path/script_name Code:
#!/bin/ksh
if cd /usr/Prepaid/Health-check 2>/dev/null;
then
find /usr/Prepaid/Health-check -name "health_*" -mtime +30 -exec rm "{}" ";"
else
cd /usr/Prepaid
mkdir Health-check
fi
logd=`date '+%Y%m%d-%H:%M'`
echo "\nAutomated health Check of HP IVR" > /usr/Prepaid/Health-check/health_$logd.log
-----------------------------------------------------------------------------------------------------
echo "\n\n---------------" >> /usr/Prepaid/Health-check/health_$logd.log
echo "SVI Call" >> /usr/Prepaid/Health-check/health_$logd.log
echo "--------------------------------------------------------------------------------" >> /usr/Prepaid/Health-check/health_$logd.log
date=`TZ=aaa00 date +%Y%m%d`
#cd /usr/mg2/svi/svicom >/dev/null 2>&1
/usr/mg2/svi/svicom/svistatjo.x -j $date -f /usr/Prepaid/log_$date.log >/dev/null 2>&1
cd /usr/Prepaid
echo "Type Inter Access Appli Called Calling Diag CnxT CnxD Node" >tempmmtstatjo
tail -5 log_$date.log >> tempmmtstatjo
st=`wc -l tempmmtstatjo | awk '{print $1}'`
if [ $st -gt 2 ]
then
echo "The following is list of upto last five calls: " >> /usr/Prepaid/Health-check/health_$logd.log
cat tempmmtstatjo >> /usr/Prepaid/Health-check/health_$logd.log
tail -1 tempmmtstatjo > tempmmtstatjo1
awk '{print $8}' tempmmtstatjo1 > tempmmtstatjo2
hourc=`awk -F"H" '{print $1}' tempmmtstatjo2`
minc=`awk -F"H" '{print $2}' tempmmtstatjo2`
let timec=$hourc*60+$minc
hourn=`date '+%H'`
minn=`date '+%M'`
let timen=$hourn*60+$minn
let gapt=$timen-$timec
let gaph=`expr $gapt / 60`
let gapm=`expr $gapt % 60`
if [ $gapt -gt 10 ] && [ $gapt -le 30 ]
then
echo "\nMajor Warning: There were no call records in the last $gapt minutes" >> /usr/Prepaid/Health-check/health_$logd.log
elif [ $gapm -gt 30 ] || [ $gaph -gt 0 ] || [ $gapt -gt 30 ]
then
echo "\nCritical Warning: There were no call records in the last $gaph hours $gapm minutes" >> /usr/Prepaid/Health-check/health_$logd.log
else
echo "\nThe last call record is of $gapm minutes ago" >> /usr/Prepaid/Health-check/health_$logd.log
fi
else
echo "Critical Warning:There were no call records found on the server for today. Please check." >> /usr/Prepaid/Health-check/health_$logd.log
fi
rm tempmmtstatjo
rm tempmmtstatjo1
rm tempmmtstatjo2
rm log_$date.log
#---------------------------------------------------------------------------------------
cat /usr/Prepaid/Health-check/health_$logd.log > /usr/Prepaid/Health-check/health-check.log
#---------------------------------------------------------------------------------------
---------- Post updated at 01:29 PM ---------- Previous update was at 11:38 AM ---------- Issue Solved! Added this line in the script after defining the shell path: . ${HOME}/.profile // Last edited by mystition; 07-02-2009 at 04:49 AM.. |
![]() |
| Bookmarks |
| Tags |
| command not running from crontab, svistatjo.x |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|