I am creating a startup script (called from rc.local) in Debian Squeeze. The startup script checks for a variable value from a file, decrements the variable and writes it back to the file, then if the variable was greater than 0 then it executes a test and reboots the system. If the variable is 0 or less than 0, then it doesn't reboot the system. My question is as follows: Suppose I realize after a couple of tests that there is a bug in the test. Is there any way to break the execute_test->reboot->repeat loop that I have set up. Putting a "sleep 1000" in the test or doing a ps aux|grep might work, but I am not sure if I shall have access to them before the rc.local scripts have run. What if I run the script in the background instead of the foreground? Would I have access to bash login shell etc. while the test is running in the background in that case?
COUNT=`cat $testFile|wc -l`
if [ $COUNT -gt 0 ];then
ARGS=`head -1 $testFile`
cd /testCode
/testCode/startTest.sh $ARGS
sed -i '1d' $testFile
echo "rebooting"
/sbin/reboot &
exit 0
fi
I know I have given very few details, since I am not sure what information would be required. I will update the question as required.
UPDATE: I ran the test. I get the login prompt before the test finishes. I had though that I would get the login prompt only after rc.local is done executing. Could someone throw light on that?
rc.local
is done executing. Why is that happening? The test can be seen running inps aux
. I had called the test as a foreground process, but I see that the status inps aux
is without a + (indicating background). This doesn't hamper my test, but why is this happening? – FirstName LastName Aug 27 '13 at 17:31/etc/rc.local
, but I see that the way it's set up on Debian, graphical logins become possible before or afterrc.local
depending on whether the script to start the display manager comes before or afterrc.local
in alphabetical order. Odd. – Gilles 'SO- stop being evil' Aug 27 '13 at 18:40/etc/inittab
,/etc/rc?.d
. Text mode prompts come from the entries in/etc/inittab
while GUI and SSH logins come from services started via/etc/rc2.d/*
(e.g./etc/rc2.d/S??sshd
,/etc/rc2.d/S???dm
). (Note: I'm simplifying a little.) This depends on the init system used: what I wrote here is for SysVinit (the default on Debian) and works differently with Upstart or Systemd. – Gilles 'SO- stop being evil' Aug 27 '13 at 19:34