I have the following command that runs a shell script that launches several python scripts for me on reboot:

@reboot sh /home/pi/repos/launcher.sh >/home/pi/logs/cronlog 2>&1

I want to modify this however to where every night at 4am my raspberry pi will reboot automatically and launch that same shell script after it reboots. I've tried the following but for some reason it's not working and I get neither reboots nor the script running:

@reboot sh /home/pi/repos/launcher.sh >/home/pi/logs/cronlog 2>&1
0 4 * * * /sbin/shutdown -r

What exactly am I doing wrong? Do I need to have these both in one command? Ideally I just want to have my shell script be ran nightly and I figured rebooting would be a decent way to ensure that any instances of the script currently running would be removed prior to launching the script again.

  • Can you be more specific about what's not working? It is not rebooting, it's not running the script, etc. – KevinO Sep 1 '18 at 3:11
  • I'm not seeing the script ran nor reboots. – Valrok Sep 1 '18 at 3:13
  • Did you check the log? It's possible that you didn't put a new line after your last entry. Press enter after the shutdown to do so. – Nasir Riley Sep 1 '18 at 3:24
  • It's not clear that the user who's running the job has permission to reboot the machine. – Kusalananda Jul 1 '19 at 8:05

use: shutdown -r now


The "now" part is not optional.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.