2

I have many raspberries located in different places. All of them are connected to my website and download videos to show on their respective monitors.

Is it possible to send some command from my website (i use php language) to reboot the raspberry remotely? That is to say, run a command from my server to reboot a raspberry pi?

My raspberries are connected to an access point which is connected to the internet, but it does not have static IP.

This guide here presumes the raspberry and the server machine are in the same network, but for my setup that is not true.

Any solution to restart the raspberry remotely (through internet) would be helpful.

Bex
  • 2,929
  • 3
  • 26
  • 34
Mohammad Alabed
  • 123
  • 1
  • 6

3 Answers3

5

You can install and run piControl, a Node.js web application to shut down or reboot your Raspberry Pi.

More info here.

To make your Raspberry Pi reachable from the Internet, you should give it a static IP address on your local network, and forward the public HTTP default port (80) to the local IP address of the Raspberry Pi.

Morgan Courbet
  • 3,703
  • 3
  • 23
  • 38
2

On your webserver you can setup a specific file to hold a command, for example

http://myserver.com/command-for-raspberry.txt

That file should hold a sequence number and a command.

Periodically (research crontab) the Raspberry Pis should download that page, check the sequence number against their saved sequence number of the latest command they run, check the command against a list of valid commands, and if so, execute the command and save the sequence number for future reference.

Then all you have to do is create the file command-for-raspberry.txt with, for example, the content

01  reboot now

put it on the server and wait for the Pis to download and execute it.

NOTE: there is no security built into this solution, and it can be easily exploited in a multitude of ways.

Bex
  • 2,929
  • 3
  • 26
  • 34
-1

From a remote machine, assuming you have a ssh server running on the Pi.

ssh root@raspberrypi reboot

or

ssh pi@raspberrypi sudo reboot

joan
  • 71,852
  • 5
  • 76
  • 108