Operating System - HP-UX
1835862 Members
4863 Online
110085 Solutions
New Discussion

Re: Sleep process problem

 
SOLVED
Go to solution
u856100
Frequent Advisor

Sleep process problem

Hi All,

I have a script that is respawned by the inittab. When the script is already running, sometimes we need to stop it for some work to be done. Unfortunately not all of us have the root password, so instead of waking the UNIX administrator up at 0'clocks in the morning, we put the script to sleep by editing the header (adding sleep 6000). When the script is killed and subsequently respawned, the script obviously spawns a sleep process. The problem we are having, is that when the sleep process 'only' is killed, and the script starts up again, eventually it will die (after a few hours), and respawn 'again'. We do not know what is causing this, and are obviously keen to find out.

many thanks
John
chicken or egg first?
10 REPLIES 10
Mark Greene_1
Honored Contributor

Re: Sleep process problem

After you modify the script, you have to kill HUP init to get it to reread the script file, because it *may* still have the old copy of the script in memory.

mark
the future will be a lot like now, only later
Nicolas Dumeige
Esteemed Contributor

Re: Sleep process problem

Editing the script header will only be taken into account for the next run. So apparently, you count on the process to die on its own (that's why you add the sleep 6000), but you are suprised when it die after a few hours. So, what's bother you is that it isn't spawn again after it dies ?
All different, all Unix
John Carr_2
Honored Contributor

Re: Sleep process problem

Hi

Mark I dont think John can kill HUP if he is not root !

John you could ask your sys admin to install sudo and give you the ability to kill HUP

:-) John.
Elmar P. Kolkman
Honored Contributor

Re: Sleep process problem

John, have you considered a sleep 3600 will sleep for 1 hour, so a sleep 6000 will only sleep for less then 2 hours?!
Every problem has at least one solution. Only some solutions are harder to find.
u856100
Frequent Advisor

Re: Sleep process problem

Hi Chaps, thanks for the responses, they are appreciated!!

The sleep values etc are irrelevant in my case as I am just preventing the script from running so I can prevent users from logging onto a weblogic instance (started, stopped by the script). The weird thing is that when I create the sleep process, kill it so that the script starts running from where it left off, the application crashes and restarts again after a time period. This time period is much larger (2-3 times) than the sleep value I specified, so it can't be that.

This has happened a couple of times now.

thanks again chaps
chicken or egg first?
Colin Topliss
Esteemed Contributor

Re: Sleep process problem

Are you able to get this script changed?

If the script is basically looping, I'd do something along the lines of getting the script to check for the presence of a file. If it finds a file, sleep. If it doesn't, then continue. The flow would be:

init program loop
if file exists
sleep 500
else
process normally
fi
endloop

Just touch the file its looking for to start the sleep process, then delete it when you want processing to continue.

Col.
Mark Grant
Honored Contributor
Solution

Re: Sleep process problem

I don't think modifying a running script will always have the results you hope for. The idea sounds clever but there must be a better way.

Can't the script be made loop arouns a "sleep" itself if, for example a file exists and you can touch and remove that file.

I do have another alternative for you which may be a bit of overkill for what you want.

THe attached script behaves like init in that it can "respawn" processes. However, with this script, processes are given named run levels. A process runs (and is respawned) within one or more run levels. Thus you could respawn your script and when you want to stop it, you just change to a run level that the script isn't in.

As an encore, the script also does various alerting things and monitors itself.
Never preceed any demonstration with anything more predictive than "watch this"
Mark Grant
Honored Contributor

Re: Sleep process problem

Pressed the wrong button!

Here's the attachment
Never preceed any demonstration with anything more predictive than "watch this"
Mark Grant
Honored Contributor

Re: Sleep process problem

You'll also need an example config file

Never preceed any demonstration with anything more predictive than "watch this"
Paula J Frazer-Campbell
Honored Contributor

Re: Sleep process problem

John

Lateral thinking:

Get the sys admin to give you full permision on the script.

if script is called fred then create an empty one called fred-do-nothing.

Routine will them be

cp fred fred.bak
cp fred-do-nothing fred

When finished reverse it

cp fred.back fred

Reason
Init will not report errors if the script exists.


Simple

Paula
If you can spell SysAdmin then you is one - anon