# Shutdown pi with Processing?

**URL:** https://discourse.processing.org/t/shutdown-pi-with-processing/13805
**Category:** Processing for Pi
**Created:** [September 4, 2019, 6:52pm UTC](https://discourse.processing.org/t/shutdown-pi-with-processing/13805 "2019-09-04T18:52:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bluemoon](https://avatars.discourse-cdn.com/v4/letter/b/bc79bd/32.png) [@bluemoon](https://discourse.processing.org/u/bluemoon)
#### Post date: [September 4, 2019, 6:52pm UTC](https://discourse.processing.org/t/shutdown-pi-with-processing/13805/1 "2019-09-04T18:52:41Z")

</div>

Hi Folks,

I was just wondering if there was a way to shutdown the raspberry pi using Processing (or a way to have Processing run the ‘sudo shutdown’ command in Terminal).

Use case: Have a GPIO button on pi that when pressed stops the Processing sketch and shuts down the pi.

Thanks!

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [September 4, 2019, 8:32pm UTC](https://discourse.processing.org/t/shutdown-pi-with-processing/13805/2 "2019-09-04T20:32:43Z")

</div>

You can do it easily with exec(…), but you need to have password-less sudo set up.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [September 5, 2019, 7:08pm UTC](https://discourse.processing.org/t/shutdown-pi-with-processing/13805/3 "2019-09-05T19:08:35Z")

</div>

> [@neilcsmith](#):
>
> but you need to have password-less sudo set up.

Depending on your operating system, you can explicitly grant your user passwordless sudo to the shutdown command only, e.g. in /etc/sudoers.d

> <https://unix.stackexchange.com/questions/85663/poweroff-or-reboot-as-normal-user/465236#465236>

Much better than leaving your user wide open.
