Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I write a script that basically just runs pkill -HUP inetd? I want to restart inetd via a script so I can schedule it to run at a particular time. I tried to write it myself, but I'm getting a "Hangup" error.

share|improve this question
Could you show us a example of what you've tried? Maybe someone could show you what you did wrong, just asking us to script for you sounds lazy. You may learn something useful for the future. – llua Apr 5 '12 at 3:31
What exactly did you do (are you running the script from a shell? from a crontab?), and what was the exact error message you got? I can't think of an use case where you would need a script instead of just running pkill directly – Michael Mrozek Apr 5 '12 at 4:32
I tried following mini script but it doesn't seems to work. #!/usr/local/bin/bash PKILL="/usr/bin/pkill -HUP inetd" MAIL="/usr/bin/mail" USER="ian@mail-server.com" sudo $PKILL $MAIL -s "inetd restarted on mail-server" $USER < /dev/null exit 0 – Ian Apr 5 '12 at 4:36
What is your operating system? – Nils Apr 5 '12 at 19:45
@Ian Edit your question. Copy-paste your script, the way you run it, and the error message you get. – Gilles Apr 5 '12 at 23:18
PID=`pidof inetd`
sudo kill -s HUP $PID
$MAIL -s "inetd restarted on mail-server" $USER < /dev/null
exit 0

If pidof is available.

share|improve this answer
Thanks llua, it works with no issues. Just out of curiosity can you tell why we can't use pkill instead kill? Thanks once again. Ian – Ian Apr 5 '12 at 7:02
Do you mind pasting the full output of the error? or was the full error returned to you was "Hangup". – llua Apr 5 '12 at 20:06
Sorry I was away for few days. Yes, "Hangup" was the total message. I am running the script on Solaris 5.7 by the way. Thanks for your assistance. – Ian Apr 11 '12 at 4:16

Your Answer


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.