3

I'm making a marquee with a Raspberry Pi where the images for the marquee are on a USB stick and the Python file that is the marquee is on the Raspberry Pi itself (RPi Zero W running Raspbian). I'm trying to use systemd and a .services file with this tutorial to run the marquee as soon as the Pi boots.

However, I think the program is running before the USB is mounted or something because the logs say that the files on the USB cannot be found. How do I make the .service file wait until the USB is mounted before it runs the python program?

Here's the myscript.service program:

[Unit]
Description=My Script Service
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/pi/Documents/base.py > /home/pi/Documents/myscript.log 2>&1

[Install]
WantedBy=multi-user.target

The USB that I want to wait for is

/media/pi/0850-9F0E/

I've heard something like RequiresMountsFor works but I have no idea how to use it. I'm new to the technical side of Linux.

1 Answer 1

0

This took me a while to figure out as well, but this thread gave me the answer. Use systemctl status to show the unit. In your case, it will probably be something like media-pi-0850-9F0E.mount.

Just tell your service to start after this is mounted:

After=multi-user.target media-pi-0850-9F0E.mount

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .