# Reboot in post script

**URL:** https://forums.suse.com/t/reboot-in-post-script/22638
**Category:** SLES Install-Boot
**Created:** [May 17, 2012, 12:24pm UTC](https://forums.suse.com/t/reboot-in-post-script/22638 "2012-05-17T12:24:18Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Neha1234](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@Neha1234](https://forums.suse.com/u/Neha1234)
#### Post date: [May 17, 2012, 12:24pm UTC](https://forums.suse.com/t/reboot-in-post-script/22638/1 "2012-05-17T12:24:18Z")

</div>

I am using SUSE 10 and I am trying to execute my script through post install script.  
And my script contains code for reboot.

My post install script looks like:  
pushd ###  
sh sample.sh  
popd

and I created link as follows:  
ln -sf /etc/rc.d/rc3.d/S99reboot

sample.sh contains code for reboot.  
It reboots However, it keeps rebooting over and over. It seems the code inside of S99reboot is never executed.

Any help will be appreciated.  
Thanks

---

<div class="post-metadata">

### Author: ![smflood](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/smflood/32/10576_2.png) [@smflood](https://forums.suse.com/u/smflood)
#### Post date: [May 17, 2012, 2:58pm UTC](https://forums.suse.com/t/reboot-in-post-script/22638/2 "2012-05-17T14:58:03Z")

</div>

On 17/05/2012 10:34, Neha1234 wrote:  
[color=blue]

> I am using SUSE 10 and I am trying to execute my script through post  
> install script.  
> And my script contains code for reboot.
> 
> My post install script looks like:  
> pushd ###  
> sh sample.sh  
> popd
> 
> and I created link as follows:  
> ln -sf /etc/rc.d/rc3.d/S99reboot
> 
> sample.sh contains code for reboot.  
> IT REBOOTS HOWEVER, IT KEEPS REBOOTING OVER AND OVER. IT SEEMS THE  
> CODE INSIDE OF S99REBOOT IS NEVER EXECUTED.
> 
> Any help will be appreciated.  
> Thanks[/color]

## Duplicate of [http://forums.suse.com/showthread.php?1074-Reboot-in-post-script](http://forums.suse.com/showthread.php?1074-Reboot-in-post-script)

Simon  
Novell/SUSE/NetIQ Knowledge Partner

* * *

## Do you work with Novell technologies at a university, college or school? If so, your campus could benefit from joining the Novell Technology Transfer Partner (TTP) program. See [novell.com/ttp](http://novell.com/ttp) for more details.

---

<div class="post-metadata">

### Author: ![Willem1](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@Willem1](https://forums.suse.com/u/Willem1)
#### Post date: [May 17, 2012, 4:56pm UTC](https://forums.suse.com/t/reboot-in-post-script/22638/3 "2012-05-17T16:56:20Z")

</div>

[QUOTE=Neha1234;4680]I am using SUSE 10 and I am trying to execute my script through post install script.  
And my script contains code for reboot.

My post install script looks like:  
pushd ###  
sh sample.sh  
popd

and I created link as follows:  
ln -sf /etc/rc.d/rc3.d/S99reboot

sample.sh contains code for reboot.  
It reboots However, it keeps rebooting over and over. It seems the code inside of S99reboot is never executed.

Any help will be appreciated.  
Thanks[/QUOTE]

Hi,

Don’t get why you are trying to do it like this… So I’m curious, why don’t you simply call a reboot or shutdown command in your script?

Cheers,  
Willem

---

<div class="post-metadata">

### Author: ![Neha1234](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@Neha1234](https://forums.suse.com/u/Neha1234)
#### Post date: [May 18, 2012, 6:28am UTC](https://forums.suse.com/t/reboot-in-post-script/22638/4 "2012-05-18T06:28:03Z")

</div>

[QUOTE=Magic31;4688]Hi,

Don’t get why you are trying to do it like this… So I’m curious, why don’t you simply call a reboot or shutdown command in your script?

Cheers,  
Willem[/QUOTE]  
Actually the code of reboot is in my sample.sh script only. But I want after every reboot my script gets executed and reboot occurs . But reboot is ocuuriong over and over and my script is never executed.  
If I create empty and linked it with S99reboot in use level 3 the same problem persist.

---

<div class="post-metadata">

### Author: ![Willem1](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@Willem1](https://forums.suse.com/u/Willem1)
#### Post date: [May 18, 2012, 8:37am UTC](https://forums.suse.com/t/reboot-in-post-script/22638/5 "2012-05-18T08:37:52Z")

</div>

> [@Neha1234;4706](#):
>
> But I want after every reboot my script gets executed and reboot occurs . But reboot is ocuuriong over and over and my script is never executed.

Ok… so if I understand correctly the server is still in a reboot loop? And you need to fix this first?

You should be able to boot into single user mode (enter “init 1” as boot option at the grub boot screen) and remove customizations made that are causing the loop (which is not clear to me as I don’t see that symbolic link you mention being the cause of that?).

In any case, I usually place a after.local script file in /etc/init.d (and chmod +x it) to let extra “stuff” get done after the server has booted. Might be that is what you are after? (as I don’t understand what you are trying to do with you script)

Cheers,  
Willem

---

<div class="post-metadata">

### Author: ![Neha1234](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@Neha1234](https://forums.suse.com/u/Neha1234)
#### Post date: [May 18, 2012, 8:55am UTC](https://forums.suse.com/t/reboot-in-post-script/22638/6 "2012-05-18T08:55:49Z")

</div>

Yes I have done the same and server has came out of reboot loop.  
And I also tried the same created file in /etc/init.d folder and chmod +x created link in user level 3 in /etc/rc.d/rc3.d/S99reboot but again the server is going in reboot loop.

---

<div class="post-metadata">

### Author: ![Willem1](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@Willem1](https://forums.suse.com/u/Willem1)
#### Post date: [May 18, 2012, 11:29am UTC](https://forums.suse.com/t/reboot-in-post-script/22638/7 "2012-05-18T11:29:44Z")

</div>

> [@Neha1234;4711](#):
>
> And I also tried the same created file in /etc/init.d folder and chmod +x created link in user level 3 in /etc/rc.d/rc3.d/S99reboot but again the server is going in reboot loop.

Once a script is placed in /etc/init.d and has the execute attribute set, you can use the insserv and chkconfig commands to control what happens during boot/change of runlevel. Doing this by hand is not something I’d recommend as the given tools also do the job at looking at placing the scripts in proper order etc.

Again, with what you are doing - and if I understand it correctly - it’s logical that the server ends up in a reboot loop… as you are starting a script at boot telling the server to reboot. I don’t see what you are trying to achieve…(??)

-Willem

---

<div class="post-metadata">

### Author: ![Neha1234](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@Neha1234](https://forums.suse.com/u/Neha1234)
#### Post date: [May 18, 2012, 11:51am UTC](https://forums.suse.com/t/reboot-in-post-script/22638/8 "2012-05-18T11:51:19Z")

</div>

Yes you are right but in my script I have passed COUNT variable for number of reboots.  
Actually through my script I want system to reboot COUNT times.  
Let say COUNT=10 than system should reboot 10 times only and then it should stop rebooting.  
But in my case it is going in infinite loop.

---

<div class="post-metadata">

### Author: ![Willem1](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@Willem1](https://forums.suse.com/u/Willem1)
#### Post date: [May 18, 2012, 1:35pm UTC](https://forums.suse.com/t/reboot-in-post-script/22638/9 "2012-05-18T13:35:43Z")

</div>

[QUOTE=Neha1234;4716]Yes you are right but in my script I have passed COUNT variable for number of reboots.  
Actually through my script I want system to reboot COUNT times.  
Let say COUNT=10 than system should reboot 10 times only and then it should stop rebooting.  
But in my case it is going in infinite loop.[/QUOTE]

Seems like something in the script ain’t workin’ 🙂

How are you writing the count values (where to) and how is it getting compared when the system boots again?

Not sure why you would need this… this is not Windows we are talking about 😛 Why so many reboots?

Cheers,  
Willem

---

<div class="post-metadata">

### Author: ![Neha1234](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@Neha1234](https://forums.suse.com/u/Neha1234)
#### Post date: [May 18, 2012, 2:20pm UTC](https://forums.suse.com/t/reboot-in-post-script/22638/10 "2012-05-18T14:20:12Z")

</div>

I am redirecting value of COUNT in file and when rebooting the system Count value is compared to COUNT\_MAX i.e.10 which is also written in file.  
But main cause is my script is never gets executed after 1st reboot because value of COUNT never goes beyond 1.

---

<div class="post-metadata">

### Author: ![Willem1](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@Willem1](https://forums.suse.com/u/Willem1)
#### Post date: [May 18, 2012, 3:13pm UTC](https://forums.suse.com/t/reboot-in-post-script/22638/11 "2012-05-18T15:13:18Z")

</div>

[QUOTE=Neha1234;4721]I am redirecting value of COUNT in file and when rebooting the system Count value is compared to COUNT\_MAX i.e.10 which is also written in file.  
But main cause is my script is never gets executed after 1st reboot because value of COUNT never goes beyond 1.[/QUOTE]

Maybe the script is been getting called to soon? (to soon as in the mount path not being available yet)… looking at the boot.msg might give some more clues.
