Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

Troubleshooting • Cannot schedule script via cronjob that runs manually

$
0
0
Hello all, I just recently did a fresh install of Raspberry Pi OS Lite (64-bit), released 05/13/2025 on my Model 3 B+, and I then installed PictureFrame using this tutorial: https://www.thedigitalpictureframe.com/ ... i-2-3-4-5/

The PictureFrame service is working as intended, but now I'd like to schedule several times to turn off and on the screen and scheduled restarts of the PictureFrame service, as sometimes it errors out and just stops running.

I have verified that these scripts work just fine when I manually execute them using a command like

Code:

. /home/pi/scripts/mon.sh
. But when I try to schedule them via a cronjob, they do not run, and I'm also getting no output in my log file I created. I'll paste the contents of my scripts and my crontab below:

My script mon.sh:

Code:

#!/bin/bashexport WAYLAND_DISPLAY=wayland-0export XDG_RUNTIME_DIR=/run/user/1000/usr/bin/wlr-randr --output HDMI-A-1 --on --mode 1920x1080
My script moff.sh:

Code:

#!/bin/bashexport WAYLAND_DISPLAY=wayland-0export XDG_RUNTIME_DIR=/run/user/1000/usr/bin/wlr-randr --output HDMI-A-1 --off
My restart_pic_frame.sh script

Code:

#!/bin/bashsystemctl --user restart picframe.service
And my crontab for my user pi

Code:

SHELL=/bin/bashPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games* * * * * echo "$(date +"%T") Hello from crontab" >> /home/pi/log/log30 16 * * 1-5 /bin/bash /home/pi/scripts/mon.sh31 16 * * 1-5 /bin/bash  /home/pi/scripts/restart_pic_frame.sh0 17-22 * * 1-5 /home/pi/scripts/restart_pic_frame.sh0 8 * * 6-7 /home/pi/scripts/mon.sh1 8 * * 6-7 /home/pi/scripts/restart_pic_frame.sh0 9-22 * * 6-7 /home/pi/scripts/restart_pic_frame.sh@reboot /home/pi/scripts/mon.sh30 22 * * * /home/pi/scripts/moff.sh* * * * * /bin/bash /home/pi/scripts/restart_pic_service.sh >> home/pi/log/log 2>&1
I also added the following to my ~/.bashrc file

Code:

# Environment Variablesexport SHELL=/bin/bashexport PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
Again, all of these scripts work just fine when I manually execute them, but nothing happens from the cronjob(s). I was also trying to troubleshoot in general, which are the two commands I have set to run every minute (they are not running).

What should I do to troubleshoot? This seems really basic, but it's stumping me.

Statistics: Posted by larsony99 — Sun Jun 15, 2025 11:01 pm



Viewing all articles
Browse latest Browse all 8015

Trending Articles