I am wondering: Is it possible to shut down or restart my Raspberry Shake (RS3D) remotely, without visiting the site at which it is placed? Or, alternatively, is there a way of scheduling RS3D to restart after a pre-specified duration?
Thank you in advance!
If you Shake is connected to the internet, thus reachable from other computers, then y, you can log in remotely via SSH as explained here: How to access your Raspberry Shake’s computer via ssh
Once in, you can execute
sudo reboot to reboot the Shake, or
sudo shutdown -h now if you want to turn it off. Be aware that, with this last option, you will need to manually turn it on again.
Alternatively, you can schedule a cronjob that will restart the Shake at set times. After accessing the unit via SSH, execute
sudo crontab -e and then add a line similar to this:
0 2 * * * /sbin/shutdown -r now
If you are not familiar with this text editor, after opening the crontab, press
i, then copy the command adjusting the time to suit your needs, then press
Esc. Now write
:wq and press Enter to save everything.
Also, in case you’re not familiar with cronjob syntax, here’s a summarized explanation:
Each part has a specific meanig, allowing you to schedule tasks on a recurring basis.
0 2 * * * - This part of the line specifies when the cron job will run.
0 - Minute (0-59)
2 - Hour (0-23, where 2 refers to 2 AM)
* - Day of the month (1-31)
* - Month (1-12)
* - Day of the week (0-7, where both 0 and 7 represent Sunday)
/sbin/shutdown - This is the command that is being scheduled.
-r - This is an option for the
shutdown command and it stands for reboot.
now specifies that the shutdown and reboot should happen immediately.
So, the entire line
0 2 * * * /sbin/shutdown -r now schedules a reboot at 2 AM every day.
Thank you very much for your answer!
To be honest, I didn’t test the scheduled restart command (added to crontab) at first, I just tested the sudo reboot option and ZetoTier.
Now that I tested the “0 2 * * * /sbin/shutdown -r now” command, I found out that it is not working for me. I am wondering if there’s anything else I should do after adding the line to the file?
Thank you for your support!
You need to add the shutdown to the root account crontab, not the myshake crontab.
I am pretty sure that myshake doesn’t have sufficient privileges to run that command.
To become root:
$ sudo su -
Now run crontab -e …
Philip is right; I forgot to add a
sudo in front of the crontab command, so that the reboot would be executed by the root user.
I have adjusted my initial message, adding some further instructions.
Thank you very much, it is working now!
Happy to heard that, Houssam!