killing a unix job after the job process gets completed


 
Thread Tools Search this Thread
Operating Systems Solaris killing a unix job after the job process gets completed
# 1  
Old 07-22-2005
killing a unix job after the job process gets completed

Hi,

Thanks in advance.

i need to kill a unix background running job after that job process completes.

i can kill a job by giving the following unix command

kill -9 processid

how to kill the job after the current process run gets completed ?

Appreciate your valuable help.

Thanks - Alo
# 2  
Old 07-22-2005
Wouldnt the background process get killed after its run ?

Look at this.

Code:
sh-2.05b$ cat sleep.sh
#! /bin/sh

echo "Going to sleep"
sleep 30
echo "Back from sleep"

sh-2.05b$ ./sleep.sh &
[1] 24400
sh-2.05b$ Going to sleep

sh-2.05b$ ps x | grep sleep | grep -v grep
24400 pts/11   S      0:00 /bin/sh ./sleep.sh
24401 pts/11   S      0:00 sleep 30


sh-2.05b$ Back from sleep

sh-2.05b$ ps x | grep sleep | grep -v grep
sh-2.05b$

And there is no trace of sleep.sh

What is happening in your case ?

Vino

Last edited by vino; 07-22-2005 at 07:58 AM..
# 3  
Old 07-23-2005
please check the sleep.sh, i ll come dear
# 4  
Old 09-10-2005
check fr the status..

check fr the status the status of the process fr which ur job is going to wait ... once it is done take the wait status and end the job
# 5  
Old 09-10-2005
This will fork off a background process to kill the script after DELAY

Code:
#!/bin/bash

DELAY=600 # seconds

kill (){
        sleep $DELAY
        kill $0
        sleep 1
        kill -9 $0
}
kill &

# Do other stuff for $DELAY seconds

# 6  
Old 09-11-2005
Assuming you have :

Have'nt tested it!

#!/bin/bash

my_function()
{
echo "This is my function"
}

my_function &
echo "Some Statement"
MY_PID=$!
kill $MY_PID
# 7  
Old 09-25-2005
check the last line on your process --- does it end with "exit 0" or does it end with the last process command? i tend to make sure my scripts' last line is "exit 0" just to make sure i don't have any process that's hanging on too long past it's shelf life ...

Code:
#! /bin/ksh

echo "My name is Johnny."
echo "The date stamp right now is $(date)."

exit 0  ## last line

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

2. UNIX for Advanced & Expert Users

Issue while killing the process using autosys job

Hi, I have one autosys job that will retrieve the proccess id's and will kill those processess as follows, pid=`/usr/ucb/ps -auwwxx | grep MAIN |nawk '{print $2}'` kill -9 pid but after executing this particular job, its status is showing as TE(terminated) and the kill process is... (3 Replies)
Discussion started by: Kattoor
3 Replies

3. Shell Programming and Scripting

System terminating diff command before job completed

I'm running diff at the command prompt against two very large text files (>1GB) and system kills the process and replys back "Terminated" after 15 seconds. I believe a system parameter needs to be adjusted but can't figure it out. I'm running Red Hat 4.1.2-46, 2.6.18-028stab089.1 Thanks... (4 Replies)
Discussion started by: azpetef
4 Replies

4. UNIX for Dummies Questions & Answers

Shell Scripts - Killing a job....

Hello all, I need to write a shell script that does the following; Allows you to kill a job,(1) listing only the jobs you own, (2) asks for which job to kill, (3) kills the job and (4) confirms kill... I am not sure if I need to first run the job command and pipe it with kill? Which options... (6 Replies)
Discussion started by: citizencro
6 Replies

5. Shell Programming and Scripting

Send an email once a job is completed

Hi, The HPCs I used earlier used PBS (Portable Batch System) to schedule when I was running various jobs and it had an option to send me an email once a job is completed. I'm wondering whether this is possible for any other process (without the use of PBS). For example, I'm running some codes... (2 Replies)
Discussion started by: lost.identity
2 Replies

6. Shell Programming and Scripting

Finding the age of a unix process, killing old processes, killing zombie processes

I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time. Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies

7. Shell Programming and Scripting

Script to Start a Job after finding the Old job completed

Hi Experts, I need a script advice to schedule 12 jobs ( SAS Codes execute back ground ). Algorithem: 1. Script checks first job. 2. Finds first job is done; invoke second job. 3. finds second job is done; invoke third job. .. Request you to please assist. (3 Replies)
Discussion started by: Jerald Nathan
3 Replies

8. UNIX for Advanced & Expert Users

Background job when completed

Hello - I submitted one background job last night and it completed today morning.I want to know exact time the job completed. I submitted backgroung job like this nohup cp -Rp /opt/apps/prod/proddb/proddata . & I want to know when above job completed on UNIX server.Above command... (9 Replies)
Discussion started by: Mansoor8810
9 Replies

9. Shell Programming and Scripting

check if job still alive and killing it after a certain walltime

Hi! I'm using a script to start a process that might run forever if some parameters are given wrong (it's part of an optimization). I would now like to have the process killed after a certain walltime in that case. So far I get it done with the following lines ./My_process.e & pid=`ps -ef |... (3 Replies)
Discussion started by: ciwstevie
3 Replies

10. Shell Programming and Scripting

killing unix job after the job process completes

Hi, Thanks in advance. i need to kill a unix background running job after that job process completes. i can kill a job by giving the following unix command kill -9 processid how to kill the job after the current process run gets completed ? Appreciate your valuable help. ... (1 Reply)
Discussion started by: dtazv
1 Replies
Login or Register to Ask a Question