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
grablogs.conf(4)						   File Formats 						  grablogs.conf(4)

NAME
grablogs.conf - grablogs configuration for libgrablogs.so of the plugins of gnome-system-log file SYNOPSIS
/usr/lib/gnome-system-log/plugins/grablogs.conf DESCRIPTION
The libgrablogs.so is a plugin for gnome-system-log(1), it colloct the log files from the system as many as possible. grablogs.conf is a configuration file that contains a set of lines mixed with sh(1) syntax codes and individual log files. libgrablogs.so will read the file try to get a log files list for gnome-system-log(1). Users can copy the file into $HOME/.gnome2/gnome-system-log/plugins/`uname -p` to overwrite the system default one. The grablogs.conf file contains the following configuration categories: [configs] Each line under this category is interpreted as a config file of System. The plugin will open the config file and try to find all system paths of the logs. [commands] Each line under this category is interpreted as a shell command and will be execute through a pipe. And each line of the out- put of the command will be interpreted as a log path. [logs] Each line under this category is interpreted as a log path. FILES
/usr/lib/gnome-system-log/plugins/grablogs.conf The system default configuration file for the plugin libgrablogs.so $HOME/.gnome2/gnome-system-log/plugins/`uname -p`/grablogs.conf The user specific configuration file for the plugin libgrablogs.so EMAMPLE
[configs] /etc/syslog.conf [commands] for i in `svcs -aH -o FMRI | grep -v lrc `; do svcprop -p restarter/logfile $i 2>/dev/null || svcprop -q -p restarter/alt_logfile $i 2>/dev/null ; done [logs] /var/log/messages /var/log/secure /var/log/maillog /var/log/cron /var/log/Xorg.0.log /var/log/XFree86.0.log /var/log/auth.log /var/log/cups/error_log SEE ALSO
gnome-system-log(1), pipelog.conf(1) gnome-utils 2.16.0 13 Oct 2006 grablogs.conf(4)
All times are GMT -4. The time now is 02:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy