- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Simple script needed quick
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2004 11:05 AM
01-30-2004 11:05 AM
Simple script needed quick
I need something on an HPUX 11.11 box that will do start named up again if it dies.
We are having some problem with it that we need to further research with HP, but because the weekend is coming up, don't want to make any major changes.
So want a simple script to do a SLEEP and to check to see if named is running. If it isn't, then start it.
Someone please help and please make it simple for me too please.
Thanks,
Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2004 11:21 AM
01-30-2004 11:21 AM
Re: Simple script needed quick
0) Install the attached namedchek.sh in /root/bin.
1) as root:
crontab -l > /tmp/rootcrontab
2) vi /tmp/rootcrontab and add this line:
2,7,12,17,22,27,32,37,42,47,52,57 * * * * /root/bin/namedchek.sh
save the file.
3) crontab < /tmp/rootcrontab
By the way, it's a pretty good idea to do the same with inetd as well. This does not mean that you shouldn't patch named or inetd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2004 11:25 AM
01-30-2004 11:25 AM
Re: Simple script needed quick
Granted you 10 points.
Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2004 11:31 AM
01-30-2004 11:31 AM
Re: Simple script needed quick
#!/usr/bin/ksh
PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/usr/contrib/bin
PROC="named"
LOG=/tmp/named_restart.log
STAMP=/tmp/named_restart.kill
INTERVAL=5
while [ true ]
do
if [ -f $STAMP ]
then
echo "$(date): $0: $STAMP file present. Exiting" >> $LOG
exit
else
NUM_PROCS=$(UNIX95= ps -fC $PROC|grep -v CMD|wc -l)
if [ $NUM_PROCS -eq 0 ]
then
echo "$(date): $0: named not running. Starting." >> $LOG
/sbin/init.d/named start >> $LOG 2>&1 # replace it with how you start your named
fi
fi
sleep $INTERVAL
done
Make sure you test it couple of times by stopping named and running the script.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2004 11:38 AM
01-30-2004 11:38 AM
Re: Simple script needed quick
Good idea not to change things before the weekend!
/root/bin doesn't exist by default in HP-UX, so you may need to do this:
mkdir -p /root/bin
before you edit the crontab as A. Clay suggested. The mkdir command creates new directories (folders) and the -p option to the command makes both directories (/root and /root/bin) at the same time. Saves typing it twice. :)
By the way, thanks for making use of the points system. Some people, such as A. Clay, spend a lot of time answering questions for free. (Unfortunately, I haven't seen his points actually show up yet, not sure if things are delayed or what...).
Good luck,
Mic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2004 11:43 AM
01-30-2004 11:43 AM
Re: Simple script needed quick
Just in case if you want to test my script, there is a space between UNIX95= and ps
UNIX95= ps -fC
^
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2004 07:21 AM
02-01-2004 07:21 AM
Re: Simple script needed quick
#!/bin/ksh
while [ 1 -eq 1 ]
do
let myProcs=`grep yourproghere|grep -v grep |wc -l
if myProcs -lt 1 then
restart your proc here
fi
sleep 10
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2004 09:08 AM
02-01-2004 09:08 AM
Re: Simple script needed quick
It runs on root cron, i send the output to a mailbox in the Outlook server 2>&1 mailx "Named daemon" someone@juf.org
nameprod=$(ps -ef | grep named | wc -l)
rc=0
if [ $nameprod -ge 1 ]
then
echo "Named is running fine"
else
echo "Cron is attempting BIND restart"
/sbin/init.d/named start
rc=$?
fi
if [ $rc -ne 0 ]
then
# Take action, email Steve's Cell phone
echo "Emailing Steve's Cell phone"
fi
Pretty simple, I'm leavin actual action of the script for you to decide because only you know how urgent it is that named id down.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com