# Using script update module to reboot device

**URL:** https://hub.mender.io/t/using-script-update-module-to-reboot-device/1412
**Category:** General Discussions
**Tags:** update-modules
**Created:** [January 7, 2020, 5:11pm UTC](https://hub.mender.io/t/using-script-update-module-to-reboot-device/1412 "2020-01-07T17:11:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![edocklea](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@edocklea](https://hub.mender.io/u/edocklea)
#### Post date: [January 7, 2020, 5:11pm UTC](https://hub.mender.io/t/using-script-update-module-to-reboot-device/1412/1 "2020-01-07T17:11:45Z")

</div>

Hi, I’d like to create a simple artifact to reboot devices using the “script” update module. I created a bash script that will reboot the device, but this reboot ends up causing the Mender client to transition to the ArtifactFailure state and report the artifact\_name as INCONSISTENT. I assume there is something I am missing with reporting to Mender that the script was actually successful as it causes a reboot before it can give an exit code…

What is the proper way to approach rebooting using the script update module? Thanks!

---

<div class="post-metadata">

### Author: ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)
#### Post date: [January 8, 2020, 9:54am UTC](https://hub.mender.io/t/using-script-update-module-to-reboot-device/1412/2 "2020-01-08T09:54:41Z")

</div>

Hi @edocklea I think the best approach here would be to generate essentially a null artifact that uses a post-commit state script to do the reboot. Any reboot that happens before the commit will result in the behavior you see. The actual update module and payload content can be essentially nothing.

Hope that helps.  
Drew

---

<div class="post-metadata">

### Author: ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)
#### Post date: [January 8, 2020, 12:01pm UTC](https://hub.mender.io/t/using-script-update-module-to-reboot-device/1412/3 "2020-01-08T12:01:58Z")

</div>

Not exactly. It will result in an infinite reboot loop, because Mender will consider the script interrupted, and will retry it the next time it starts. However, if you make sure to save the fact that you rebooted somewhere, and return success the next time the Commit\_Leave script is executed, then it should work.

---

<div class="post-metadata">

### Author: ![edocklea](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@edocklea](https://hub.mender.io/u/edocklea)
#### Post date: [January 9, 2020, 9:17pm UTC](https://hub.mender.io/t/using-script-update-module-to-reboot-device/1412/4 "2020-01-09T21:17:50Z")

</div>

Thanks for the responses! Just in case it helps someone else, I ended up creating a null artifact with an ArtifactCommit\_Leave state script that handles checking reboot status as suggested. I check if a temp file exists and if so, remove it and exit successfully so the Mender client can complete the update. Otherwise, I create that temp file and do the reboot.
