![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error in cron job; | shruthinagaraj | UNIX for Dummies Questions & Answers | 1 | 10-28-2008 10:27 AM |
| 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 |
| Script/cron error | Bab00shka | UNIX for Dummies Questions & Answers | 1 | 06-12-2002 07:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 ... |
|
||||
|
I suspect that one of your kills is killing the login shell as well as the intended program.
This section of script may be the problem rm $touchfile /usr/local/bin/killpg $$ exit -1 I depends what "killpg" actually does. It is not a standard unix command. Or possibly this area of script which ruthlessly kills parents and children of $WAITPROC. /usr/proc/bin/ptree $WAITPROC | awk '{ print "kill -9 " $1 " 2> /dev/null "}' | ksh BTW. Use "kill -9" at your peril. It is a last resort and not a way to end things tidily. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|