killing a process pid

What option is used with kill to cause the server to reread its config file.

If you want to kill the server, Control + C usually helps. A kill command is not the perfect solution.

Anyway, ps aux will give you the process id running in the system.

Pick the pid of your choice and issue a kill -9 pid

is there a way to find the pid # and issue the kill with one command line?

strange ?'s i know, this is for a class.

I would say using kill -9 pid is not the better choice in most of the situations,
where the process intended to kill is poorly deprived of doing any sort of cleanup operations. Most of the programs would have implemented ( if not, that cannot be helped ) or rather registered signal handlers and that signals should only be delivered for a safe and clean kill possibly. SIGTERM should have been registered in most of the cases and it would be better to go with that instead of the merciless kill. :slight_smile:

This had been answered many times. Please use the SEARCH facility. :slight_smile:

Anyway you could use,

just a pointer, you need to refine that

kill -<SIGNAL> `ps -ef | grep <processname> | awk '{print $2}'`

keep getting
arg must be a process of job id

Can you please post, what is the exact command that you had run and the error message you get?

.............

This is not the command said above,
should be like

kill -9 `ps -ef | grep vi | awk '{print $2}'`

take care of the backticks
before executing the kill command, make sure with the list of pids that only the correct process is being terminated :slight_smile:

THANKS MUCH
works like a champ, as far as the , What option is used with kill to cause the server to reread its config file. Is there an option for this or does this happen if the init process is killed?

This question doesn't make sense. What server are you talking about? (If you're referring to inetd, "man inetd" should help. ) Didn't you say this was a homework question?

Oh, and if you kill the init process, you shutdown the machine. ( Init is the parent, grandparent, etc, of all other processes. )

The reason you can't just kill a process by the command name is that there may be multiple commands running with the same name. For example, If I'm logged in with bash, and Bob is also logged in with bash, and I try to kill "bash", which one will it kill?

If you want to kill every possible instance of a command with a certain name, "killall" is available on some systems.

thanks for the info

-9 is a force kill, what you want is -1 which is the same as -HUP

kill -1
or
kill -HUP

FYI....
The signals currently defined by <signal.h> are as follows:

     Name             Value   Default    Event
     SIGHUP           1       Exit       Hangup
     SIGINT           2       Exit       Interrupt
     SIGQUIT          3       Core       Quit 
     SIGILL           4       Core       Illegal Instruction
     SIGTRAP          5       Core       Trace or Breakpoint Trap
     SIGABRT          6       Core       Abort
     SIGEMT           7       Core       Emulation Trap
     SIGFPE           8       Core       Arithmetic Exception
     SIGKILL          9       Exit       Killed
     SIGBUS           10      Core       Bus Error
     SIGSEGV          11      Core       Segmentation Fault
     SIGSYS           12      Core       Bad System Call
     SIGPIPE          13      Exit       Broken Pipe
     SIGALRM          14      Exit       Alarm Clock
     SIGTERM          15      Exit       Terminated
     SIGUSR1          16      Exit       User Signal 1
     SIGUSR2          17      Exit       User Signal 2
     SIGCHLD          18      Ignore     Child Status Changed
     SIGPWR           19      Ignore     Power Fail or Restart
     SIGWINCH         20      Ignore     Window Size Change
     SIGURG           21      Ignore     Urgent Socket Condition
     SIGPOLL          22      Exit       Pollable Event 
     SIGSTOP          23      Stop       Stopped (signal)
     SIGTSTP          24      Stop       Stopped (user)
     SIGCONT          25      Ignore     Continued
     SIGTTIN          26      Stop       Stopped (tty input)
     SIGTTOU          27      Stop       Stopped (tty output)
     SIGVTALRM        28      Exit       Virtual Timer Expired
     SIGPROF          29      Exit       Profiling Timer Expired
     SIGXCPU          30      Core       CPU   time   limit   exceeded
     SIGXFSZ          31      Core       File   size   limit   exceeded
     SIGWAITING       32      Ignore     Concurrency   signal   reserved    by
                                         threads library
     SIGLWP           33      Ignore     Inter-LWP signal reserved by  threads
                                         library
     SIGFREEZE        34      Ignore     Check point Freeze
     SIGTHAW          35      Ignore     Check point Thaw
     SIGCANCEL        36      Ignore     Cancellation   signal   reserved   by
                                         threads library
     SIGXRES          37      Ignore     Resource   control   exceeded

The ones that interest you would be the exit ones, like 1, 2, 9 etc...

Regarding the pid, If its Solaris 9(I think some linux has it to) you could use pgrep to get the pid or just use pkill instead of kill

It depends on the how the program is coded to handle any signal for rereading the configuration file. Not necessarily it should be -HUP signal, any signal could be registered for the same. But as in most of the cases HUP would be used by a running process to read the new configuration entries

On any standard [ I mean developed using the standards ] will accept a "kill -1" to re-read it's configuration. An example would be "inetd" process.