Automatic script in Solaris to reload configuration

magitek
magitek used Ask the Experts™
on
Hey all~

I'm trying to create a script of some sort on my Solaris box to automatically "kill -HUP 12531" every 15 minutes or so.  Any suggestions on how I can do this?

We're running SunOS 5.9, primarily using the bash shell.

I'd appreciate some help!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
either
#!/bin/bash
while true
do
kill -HUP 12531
sleep 900
done


or edit your cron (crontab -e) and add
0,15,30,45 * * * * kill -HUP 12531

Author

Commented:
tried the first option, got back:

bash-2.05# ./autoconf
./autoconf: bad interpreter: Permission denied

I am running the script as root user

Please advise! Thanks!

Commented:
ok,
path to bash is wrong.
Either replace #!/bin/bash with #!/bin/sh
or type
which bash
and make the line #!/path/to/bash
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Commented:
BTW I wouldn't use the name autoconf, it is already a Solaris program.  What about autoconf.sh ?

Commented:
Just a small point. Why use bash rather than ksh for such a simple script. Bash is twice the size of ksh and is less efficient.

Author

Commented:
did the which bash and replaced it with the proper #!/usr/bin/bash

but, it still gives me the error.  (and I did change the name now to autoconf.sh, thanks)

Commented:
best bet then change it to #!/bin/sh or #!/usr/bin/ksh as glassd says, they're fine for this script
if your type
kill -HUP 12531
do you get an error message?
 If it is still a problem paste the entire script here and the error message

Author

Commented:
kill -HUP 12531 works just fine.  (i've been having to do it every 15-30 minutes, pain in the behind!)

Just the script gives the error and I don't know why.  Here's what I've got now...


#!/usr/bin/ksh
while true
do
kill -HUP 12531
sleep 900
done

Is there a specific location this script needs to be located in?

(i appreciate all your help.  our network tech passed away this last weekend leaving me to put the pieces back together....me who hadn't touched unix in almost 2 years.  bah)

Commented:
no any location,
what is the exact error?
Do you have any blank lines at the top of the file (remove them)
what is the permissions on the script? (ls -l autoconf.sh)

Author

Commented:
The reply from the permissions:
-rw-r--r--   1 root     other         60 Oct 23 10:51 autoconf.sh

no blank lines.

exact error:

bash-2.05# ./autoconf.sh
bash: ./autoconf.sh: bad interpreter: Permission denied

Commented:
Ah! the file is nor executable
chmod +x ./autoconf.sh

Author

Commented:
Thanks! That got it to work!

One more easy question, then you get your points :-D

How can I keep that running in the background so I don't have to keep a term open with it running?

Commented:
I was about to suggest you do that..but I was waiting to see if it worked!

nohup ./autoconf.sh &

Author

Commented:
THANK YOU!!!!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial