How to get a tty to respawn x number of times then pauses y number of seconds then repeat.
I am using Fedora 11 and Upstart 0.3.9.24.fc11. I am using qingy to autologin into a c3270 mainframe emulation session. If the session is unavailable, the tty closes and respawns. What I am trying to do is have the tty respawn 10 times then pauses for 5 minutes if it is unsuccessful then try 10 more times repeating this process until it is successful. This worked on Fedora 5 when we placed the following line in the /etc/inittab file:
3:2345:
My current /etc/event.d/tty3 file looks like this:
_______
start on stopped rc2
start on stopped rc3
start on stopped rc4
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
env COUNTER=1 ##Assuming this is resetting my counter, but I cannot find another way to set the initial
pre-start script
if [ $COUNTER -eq 10 ] ; then
COUNTER=1
export COUNTER
sleep 300
else
sleep 5
COUNTER=$(( $COUNTER + 1 ))
export COUNTER
fi
end script
respawn
exec /usr/local/
_______
If the session fails and tty3 is stopped it will respawn and go through the Else part of the statement above causing it to sleep for 5 seconds then respawn again. However the incremented COUNTER variable is never saved and the IF part of the statement is never true.
My questions are:
1. Is there another way to set the initial COUNTER value to 1 that doesn't wipe out the incremented values?
2. Has anyone found a better approach to getting a tty to respawn like this?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- upstart Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Scott James Remnant (Canonical)
- Solved:
- Last query:
- Last reply: