You can help yourself by collecting any error messages that are generated when cron
runs your scripts. As you're aware, your shell will send error messages to the stderr
stream when they occur. When you run the program from your terminal screen, this stderr
stream goes to your terminal, and you see it. However, your cron
job does NOT run under your userid, and its stderr
stream does NOT go to the screen.
Fortunately, Linux allows us to "redirect" the stderr
stream, and we can redirect it to a file on our system. Doing this is very simple, but the command itself will seem arcane until you study it for a bit. You can redirect the error messages from your cron
jobs by changing your crontab
file as follows:
@reboot /home/pi/launchjuvia.sh >> /home/pi/cronjoblog 2>&1
@reboot /home/pi/launchfuta.sh >> /home/pi/cronjoblog 2>&1
After reboot, you can inspect the file /home/pi/cronjoblog
, and read any error messages. If you have trouble deciphering the error messages, feel free to post them here & we'll try to help.
A coupla' other notes:
- I don't think you need to call out
bash
in your crontab
.
- I don't understand what you're doing with the first line in your
crontab
. If you're trying to schedule a reboot
recall that sudo
is normally required (i.e. sudo reboot
instead of reboot
). In any case, I'd recommend you resolve the errors in your script first, then tackle your scheduled reboots once you have that sorted.
- @Ingo's answer also has merit.
systemd
is technically superior to cron
in some respects - an important one being that it has knowledge of resource availability during the boot process. However, cron
is (IMHO) simpler, and inserting a sleep
command in your crontab
will usually resolve resource availability issues. For example:
@reboot /bin/sleep 10; /home/pi/launchjuvia.sh >> /home/pi/cronjoblog 2>&1
This will postpone execution of your shell script for 10 seconds after cron
starts, and by then the resources needed for successful execution may be available. You may need to experiment a bit to find the "best" value for sleep time.