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
crontab(5)							File Formats Manual							crontab(5)

Name
       crontab - clock daemon table file

Syntax
       /usr/lib/crontab

Description
       The  command  executes  at  specified dates and times according to the instructions in the file. The file consists of lines with six fields
       each.  The format for a line is as follows:

	      minute hour day month weekday command

       The following list defines each field in the line:

       minute (0-59)  The exact minute that the command sequence executes.

       hour (0-23)    The hour of the day that the command sequence executes.

       day (1-31)     The day of the month that the command sequence executes.

       month (1-12)   The month of the year that the command sequence executes.

       weekday (1-7)  The day of the week that the command sequence executes. Monday = 1, Tuesday = 2, and so forth.

       command	      The complete command sequence variable that is to be executed.  Note that the command string must conform  to  Bourne  shell
		      syntax.

       The first five integer fields may be specified as follows:

       o   A single number in the specified range

       o   Two numbers separated by a minus, meaning a range inclusive

       o   A list of numbers separated by commas, meaning any of the numbers

       o   An asterisk meaning all legal values

       The sixth field is a string that is executed by the shell at the specified times.  A percent sign (%) in this field is translated to a new-
       line character.	Only the first line of the command field, up to a percent sign (%) or end of line, is executed by the  shell.	The  other
       lines are made available to the command as standard input.

Examples
       The following example is part of a file:
       # periodic things
       0,15,30,45 * * * * (echo '^M' `date`; echo '') >/dev/console
       0,15,30,45 * * * * /usr/lib/atrun

       # daily stuff
       5 4 * * * sh /usr/adm/newsyslog
       15 4 * * * ( cd /usr/preserve; find . -mtime +7 -a -exec rm -f {} ; )
       20 4 * * * find /usr/msgs -mtime +21 -a ! -perm 444 -a ! -name bounds
	    -a -exec rm -f {} ;

       # NOTE: The above line is wrapped.

       # local cleanups
       30 4 * * * find /usr/spool/mqueue -type f -mtime +5 -name df-exec rm {} ;
       35 4 * * * find /usr/spool/mqueue -type f -mtime +5 -name tf-exec rm {} ;
       40 4 * * * find /usr/spool/rwho -type f -mtime +21 -exec rm {} ;
       #

       # redirecting error output
       0 17 * * 1,3,5 /bin/tar -cv /usr/sysads/smith > /dev/console 2>&1
       #

Files
See Also
       sh(1), cron(8)
       Guide to System Environment Setup

																	crontab(5)
All times are GMT -4. The time now is 08:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy