Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am new to Shell Scripting.

I saw this Command on a Book for Linux shell Scripting

$ kill -HUP 1234 >killout.txt 2>killerr.txt

I know what the command does, but i am not able to understand the flags -HUP

please shed some light on it.

I did a manual page search for the kill command but could not find any answers.

share|improve this question
    
man kill; apropos signal –  Martin Schröder May 7 '13 at 20:57

2 Answers 2

up vote 6 down vote accepted

Under Linux try man 7 signal.

kill -HUP 1234 means "send the SIGHUP signal (1) to process 1234", so it's equivalent to kill -1 1234. The default signal that is sent by kill is SIGTERM (15), so kill 1234 is equivalent to kill -TERM 1234 or kill -15 1234.

share|improve this answer
1  
Note that the POSIX syntax is kill -s HUP. kill -HUP and kill -1 are Unix (XSI extension in the SUS) but not POSIX. Note that kill -s HUP and kill -1 are the same as per Unix, but the signal number for HUP is not guaranteed to be 1 (in case you expect a process killed with HUP to return an exit status of 129 or 257) –  Stéphane Chazelas May 5 '13 at 20:38

-HUP isn't the three flags H, U, P as in the common single-letter option syntax. For historical reasons, the kill command takes an optional signal name or signal number preceded by a dash (-).

kill -1 1234
kill -HUP 1234

(As opposed to kill 1 1234, which would send the default signal (SIGTERM) to processes 1 and 1234.)

Your man page probably lists something like this:

kill [ -signal | -s signal ] pid ...

That -signal means that you can use a dash followed by a signal designation (which can be a name or number). Alternatively, you can use the -s option followed by a signal name; these are two different syntaxes with the same meaning.

kill -l lists the available signal names and the corresponding numbers.

Most signals have a predefined meaning based on who sends them when and how processes are supposed and able to react to them.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.