Email engine cron problem.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Email engine cron problem.
# 8  
Old 11-11-2010
The original script contains a syntax error (a space character after PID=) and a logic error because it will kill itself because it's own command line contains the string "AREmail" ! Also I believe that the logfile redirect is in the wrong place.

Maybe try this alternative construct

Code:
#!/usr/bin/ksh
SCRIPT_NAME="`basename $0`"    # Name of this script
(
ps -eaf | grep "AREmail" | grep -v "grep" | grep -v "${SCRIPT_NAME}" | \
    awk '{print $2}' | while read PID
    do
        echo "killing ${PID}"
        # Remove echo when tested
        echo "kill -9 ${PID}"
    done
) 2>&1 >/opt/remedy/ar/AREmail/email_kill.out

# 9  
Old 11-12-2010
30 * * * * /opt/remedy/ar/AREmail/email_kill.sh
# 10  
Old 11-17-2010
Quote:
Originally Posted by nixhead

Code:
#! /usr/bin/ksh
PID= `ps -eaf | grep AREmail | grep -v grep | awk '{print $2}'` > /opt/remedy/ar/AREmail/email_kill.out 2>&1'
 
kill -9 "$PID"


You can get pid with pgrep command in Solaris.

HTML Code:
pgrep -f AREmail
If there are multiple AREmail process, either command may get multiple PIDs , You has to use loop to kill each one.

Code:
 
pgrep -f AREmail | xargs kill -9

or

Code:
 
pkill -9 -f ARemail


Last edited by honglus; 11-17-2010 at 08:36 PM..
This User Gave Thanks to honglus For This Post:
# 11  
Old 11-17-2010
I will try this in lab for sure Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

2. Shell Programming and Scripting

I want to send an email after cron job

I am using centos 6.4. I have a few cron jobs setup and they all work fine. However, I would like to enhance one of the crons. This is what I have at the moment: nice rsync -au /home/samba/wsaler/* /home/samba/wsaler.backup/wsaler.backup18pm date | /bin/mail -s "wsaler 3:00pm backup... (8 Replies)
Discussion started by: countrydj
8 Replies

3. Solaris

Facing problem with installing CF engine software in solaris 10

Dear experts, I am using solaris 10 OS.I am installing CF engine software in the server while doing so ,i am getting following error checking for BerkeleyDB location in default... configure: error: >> Cannot find BerkeleyDB I am installing the Berkely DB 5.3.I am strugging... (1 Reply)
Discussion started by: muraliinfy04
1 Replies

4. Red Hat

Email program using CRON

Hi Guys... I have a bulk email program that sends out an email to a subscribed mail list. The list contains around 2000 addresses. My server is Centos 5 64bit PHP 5.2 Mysql 5.1 The program is set to send emails in batches of 100. Cron is set to run every minute Now for the problem:... (2 Replies)
Discussion started by: countrydj
2 Replies

5. Shell Programming and Scripting

Cron Job Automated Email Alternatives?

Hi guys, not sure if this would be the right place for this but I dont where else it would go... I'm new to Unix too, so please bare with me :) I guess first up some background on the situation. We have some scripts that run as cron jobs which monitor and check the health, etc of our servers.... (2 Replies)
Discussion started by: BrianD
2 Replies

6. UNIX for Dummies Questions & Answers

Cron to delete email help needed

I would like to know if I can place a cron job (and what it might be of course) to delete all the mail in an inbox? Here are the servers specs: Operating systemLinuxService StatusClick to ViewKernel version2.6.28.9Machine Typei686Apache version2.2.11 (Unix)PERL version5.8.8Path to... (2 Replies)
Discussion started by: markmatu
2 Replies

7. AIX

Cron Job notification email

Hi, I'm fairly new to Aix and am looking for some help on the following. I have setup a cron job under root and want it to send the email once it's run to an external email address. I can get it to send the output in an email to me by using mail on the end of the crontab entry. But I would... (1 Reply)
Discussion started by: elmesy
1 Replies

8. AIX

Problem with Cron Email Notification

I have two different cron jobs that run on the same days. The jobs are 7 hours apart. Both jobs are set to send notification emails when they start running. Both jobs always run successfully, but I only receive an email from the first job. I never get the email from the second job. ... (1 Reply)
Discussion started by: sasaliasim
1 Replies

9. UNIX for Dummies Questions & Answers

Cron Email Problem

I have two different cron jobs that run on the same days. The jobs are 7 hours apart. Both jobs are set to send notification emails when they start running. Both jobs always run successfully, but I only receive an email from the first job. I never get the email from the second job. ... (0 Replies)
Discussion started by: sasaliasim
0 Replies

10. UNIX for Dummies Questions & Answers

email when cron fails

I have a cronjob scheduled to run everyday. How can I obtain an email if and only if the cronjob fails? I am using Sun Solaris (ksh). :rolleyes: (7 Replies)
Discussion started by: inpavan
7 Replies
Login or Register to Ask a Question