Operating System - HP-UX
1751741 Members
5968 Online
108781 Solutions
New Discussion юеВ

Re: looking scrip which can execute every 5 min without crontab

 
pratapvfr
Advisor

looking scrip which can execute every 5 min without crontab

Hello i have a small scrip i need to execute in a hpux box. i tried to execute with crontab but its having some issue. this hpux box is unix 9 old version.

can some one help me to execute this script every 5 min without without crontab help.
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: looking scrip which can execute every 5 min without crontab

It is better to fix it so it works in crontab than to use sleep and at(1).
What problems do you have with crontab? Did you remember that your shell environment is limited?
pratapvfr
Advisor

Re: looking scrip which can execute every 5 min without crontab

Hello below is the sample scrip. i had saved it in /tmp/scp.txt i need to execute this every 5 min without crontab what changes i should do in this scrip.


h=`service httpd status|awk {'print $3'}`

if [ $h = "stopped" ]
then
service httpd start
fi
Dennis Handly
Acclaimed Contributor

Re: looking scrip which can execute every 5 min without crontab

while true; do
h=$(service httpd status | awk '{print $3}')
if [ "$h" = "stopped" ]; then
service httpd start
fi
sleep $(( 5 * 60 ))
done

(Assuming that the calls to service don't take any time.)
kemo
Trusted Contributor

Re: looking scrip which can execute every 5 min without crontab

adding to Mr. Dennis, run the script using at command. or use nohup before the script name.

e.g
nohup ksh /tmp/scp.txt &