LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-16-2003, 11:22 AM   #1
mum_03
LQ Newbie
 
Registered: Apr 2003
Posts: 2

Rep: Reputation: 0
restart a process


hi list -

i want to restart a process, but don't know how to supply pid of this process to kill. my script is

1. ps -ef | grep PROCESS > file (### to get current proces id )

2. cut -c8-15 file (### to get only pid)

3. I want to give the output of #2 as an argument to
kill -HUP command

Pls help.

thnks in advance
 
Old 04-16-2003, 11:36 AM   #2
Donald1000
Member
 
Registered: Oct 2002
Location: Germany
Distribution: Debian, Non-Linux: Solaris, FreeBSD
Posts: 107

Rep: Reputation: 15
Try this:
kill -9 `ps -A | awk ' ($4=="programmtokill") {print $1}'`
 
Old 04-16-2003, 06:00 PM   #3
EvilTwinSkippy
Member
 
Registered: Mar 2003
Location: Philadelphia, PA
Distribution: RedHat, Gentoo
Posts: 51

Rep: Reputation: 15
killall

The killall will pattern search for the name of the program that is running the process

killall -9 named

will nuke all of the name server processes on the machine, without predjudice.
 
Old 04-19-2003, 05:44 AM   #4
mum_03
LQ Newbie
 
Registered: Apr 2003
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Donald1000
Try this:
kill -9 `ps -A | awk ' ($4=="programmtokill") {print $1}'`

---------------

hi Donald1000 -

thks for your support. however above soln did not help. It just killed the process - whereas i want to restart the PROCESS / program.

look forward to your response
 
Old 04-19-2003, 07:09 AM   #5
phoeniXflame
Member
 
Registered: Feb 2003
Location: Somewhere, UK
Distribution: Slack, OpenBSD, Debian, SuSE
Posts: 189

Rep: Reputation: 30
Quote:
Originally posted by mum_03
---------------

hi Donald1000 -

thks for your support. however above soln did not help. It just killed the process - whereas i want to restart the PROCESS / program.

look forward to your response
kill -HUP process

???

EDIT: sorry, I didnt read your first post fully

Last edited by phoeniXflame; 04-19-2003 at 07:10 AM.
 
Old 04-21-2003, 12:43 PM   #6
Donald1000
Member
 
Registered: Oct 2002
Location: Germany
Distribution: Debian, Non-Linux: Solaris, FreeBSD
Posts: 107

Rep: Reputation: 15
Hi!
I don't know a command, that can restart the programm, but you can write a Shell Script like this:
----
#!/bin/sh
kill -9 `ps -A | awk ' ($4=="programmtokill") {print $1}'`
/usr/local/bin/programm to start
----
Make it executable with "chmod +x (filename)"
First it kills the programm pids and then restart it.
I hope it helps!
 
Old 04-21-2003, 12:51 PM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well the -HUP will cause the program to reinitialize, they already seem to know that, so why they haven't just obiovusly replaced -9 for -HUP i'm not sure really.....
 
Old 04-21-2003, 02:37 PM   #8
taarnak
LQ Newbie
 
Registered: Feb 2003
Distribution: Redhat, Solaris, Suse, Debian
Posts: 16

Rep: Reputation: 0
I have the following command in my script to restart named, hope it helps:

kill -HUP `cat /etc/named.pid`
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
kill/restart process pass Linux - General 24 02-23-2006 04:45 PM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 01:19 PM
Does kill -HUP <id> restart the <id> process? feetyouwell Linux - Software 1 02-15-2004 10:48 PM
Allowing regular user to restart network process?? carlos123 Linux - Networking 2 12-03-2003 03:44 AM
cron job to restart process if dead gborrageiro Linux - General 3 09-25-2002 11:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration