The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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
cron entry error capeme Shell Programming and Scripting 6 10-26-2006 10:05 AM
cron error capeme UNIX for Dummies Questions & Answers 4 10-25-2006 04:07 PM
mmap error - only when from cron?!?!? Bicks Filesystems, Disks and Memory 1 08-01-2006 02:12 PM
LAuS error messages in /var/log/cron soliberus Red Hat 1 05-18-2006 11:43 AM
Script/cron error Bab00shka UNIX for Dummies Questions & Answers 1 06-12-2002 07:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-28-2008
shruthinagaraj shruthinagaraj is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
Exclamation Error in cron job;

Hi All,

please help me out with this problem.

While running my mail_out_original.ksh in CRT window, it disconnects from the server saying not connected

Here is my code : (please see the attachment)
____________________________________________________________

#!/bin/ksh

## Load .profile to make sure crontab run jobs are loading all env variables
. $HOME/.profile

## Change into the directory
cd /u/gcsm_admin/mail_out

## Create the touch file
touchfile="/u/gcsm_admin/mail_out/running"

## If there is no other mail_out running the remove the touchfile
NOTRUN=$(ps -ef | grep "mail_out.ksh" | wc -l)
if [ $NOTRUN -le 2 ]
then
rm $touchfile 2>/dev/null
fi

## Exit routine
fnExit()
{
if [ -r $touchfile ]
then
rm $touchfile 2>/dev/null
fi
exit -1
}

## Set a trap to remove the touch file
trap fnExit ERR

## If we are already running then exit
if [ -r $touchfile ]
then
exit
fi

## Create a touch file
touch $touchfile

## Extra process to restart if something hangs
(
PARENT=$$
sleep 600
RUNNING=$(ps -ef | egrep "$PARENT.*mail_out" | wc -l)
if [ $RUNNING -gt 1 ]
then

echo "The pop email processor has been restarted.

Please verify this process actually worked by checking if email from case updates are being sent.

Thanks,

Support" | mailx -s 'MAIL OUT PROGRAM DOWN!' nagarajec@gmail.com
rm $touchfile
/usr/local/bin/killpg $$
exit -1
fi
)&
WAITPROC=$!

cnt=0

while [ $cnt -lt 1 ]
do

## Increment our counter
cnt=$(expr $cnt + 1)

## Run the program
/u/gcsm_admin/mail_out/mail_out.pl
sleep 1
done

## Get rid of the touch file
rm $touchfile

## Kill the monitor process and exit
trap "" ERR
/usr/proc/bin/ptree $WAITPROC | awk '{ print "kill -9 " $1 " 2> /dev/null "}' | ksh
exit 0


____________________________________________________________


your help will be appreciated ...
Attached Files
File Type: doc New Microsoft Word Document.doc (66.0 KB, 17 views)
  #2 (permalink)  
Old 10-28-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
double posting

thread closed.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0