Sponsored Content
Top Forums UNIX for Dummies Questions & Answers A command in a script not running in Crontab. Post 302330652 by mystition on Thursday 2nd of July 2009 03:59:42 AM
Old 07-02-2009
Bug

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 05:49 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

issue with running script with crontab

I am facing a strange issue while running a script(eg A) from the crontab entry the script calls one more script(eg B) within it now when i run the script A manually(with nohup) it also executes the script B (embedded inside it) as expected. but when i run the script A from the crontab entry... (7 Replies)
Discussion started by: mad_man12
7 Replies

2. UNIX for Dummies Questions & Answers

Getting error when running script through crontab

Hi all, I wrote small script for Solaris and when I am running it through command prompt its ok, but when I trying to run it using crontab, i am getting error like: ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory /tmp/file.sh: line 5: 8304 Killed ... (4 Replies)
Discussion started by: nypreH
4 Replies

3. Shell Programming and Scripting

Problem with crontab running a script

I am trying to use the CRON utility in Fedora 11 & CentOS... I intend to run a script which pops up a warning message every hour and i made the following entry using "CRONTAB -e " * * * * * sh /bin/myscript.sh But this does not seem to be running. Another thing to note is that,... (4 Replies)
Discussion started by: Vabiosis
4 Replies

4. Shell Programming and Scripting

Running SQLPLUS Script in CRONTAB

Hi, Can someone please help me here with this one. This is my script: # more tosh.sh #!/usr/bin/ksh clear . /home/oracle/.profile echo "Good morning, world." export ORACLE_HOME=/u01/app/oracle/product/9.0.1 export PATH=$ORACLE_HOME/bin:/usr/local/bin export ORACLE_SID=xxxx ... (11 Replies)
Discussion started by: santoshpayal
11 Replies

5. Shell Programming and Scripting

Crontab not running a script

Hi, I posted this in the Solaris forum but I think this one would be more appropriate. I created a script starting with the following lines: #!/usr/bin/ksh flag=n export flag typeset -i quant=0 (...) When running it I'm getting the following 2 errors: /tmp/tstscript/testfail.ksh:... (9 Replies)
Discussion started by: Cvg
9 Replies

6. UNIX for Advanced & Expert Users

Particular script not running through crontab

Hi, I have created the below script, set -x # Set the Path of Environment file ENV_FILE_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/bin LOG_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/log export ENV_FILE_DIR export LOG_DIR # Set Audit Environment . ${ENV_FILE_DIR}/QDM.env... (8 Replies)
Discussion started by: yohasini
8 Replies

7. UNIX for Dummies Questions & Answers

crontab not running script

Hi All, I am having the below script to be run from crontab, it it doesnt run. 1 * * * * /home/cobr_ext/test.sh > /home/cobr_ext/temp.txt when i run i manally it runs without any issues. Could please help me as to why doesnt it run the script.:( (7 Replies)
Discussion started by: abhi_123
7 Replies

8. Shell Programming and Scripting

Delay in running script from crontab

I am facing an issue where sometimes crontab is running script with some delay. Below is the stmt in script and it is the only stmt in script. echo "running at `date` " >> CRONCHECK.log Below is the cron entry. 0 11 * * * CRONCHECK.sh Below is the time of run each day. running at Fri... (8 Replies)
Discussion started by: Nishant Singh
8 Replies

9. Solaris

Script problem when running on crontab

Hi guys! I created a backup script that works fine when I run manually, but when I put a crontab job to execute it the result are not the expected. (not a time problem). Here is my script: bash-3.00# cat /bk_tool/backup2.sh #!/usr/bin/csh clear set DIR_HOST='SCP08' ... (3 Replies)
Discussion started by: andredemartini
3 Replies

10. UNIX for Dummies Questions & Answers

CRONTAB - one python script is not running

Hi! I'm using a RaspberryPi with standard Raspbian. Currently I'm working on some sort of weather station. For now I have three python scripts - one which is updating txt files for website - update1m.py ( it will not be necessary in few next days so I'll delete it) , second one for updating... (4 Replies)
Discussion started by: bartocham
4 Replies
KEP_RELOAD(1)						      General Commands Manual						     KEP_RELOAD(1)

NAME
kep_reload - Update Predict's Keplerian elements SYNOPSIS
kep_reload DESCRIPTION
KEP_RELOAD is a simple utility that forces an immediate reload of PREDICT's Keplerian database through a socket connection while PREDICT is running in server mode. It is especially useful in environments where PREDICT runs continuously, and periodic Keplerian element updates are made outside of PREDICT, such as through scripts run through a crontab. The "kepupdate" script found in this directory is an example of a Keplerian element update script that can be run on an automated basis through a crontab. It is designed to be placed in your home directory under a subdirectory called "cronjobs". It downloads Keplerian orbital data from www.celestrak.com using the HTTP protocol. (The "wget" utility, available from the Free Software Foundation, is required, and is included in many Linux distrubutions.) Type crontab -e to edit your crontab. Simply add the following entry: 0 8 * * * kepupdate and your orbital database will update each morning at 8:00 AM (provided you have a network connection at that time). See the crontab man page for more information on editing your crontab. AUTHOR
This man page was written by A. Maitland Bottoms, AA4HS, for Debian GNU/Linux. 31 August 2003 KEP_RELOAD(1)
All times are GMT -4. The time now is 02:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy