Search code examples
raspberry-pisystemd

Raspberry Pi systemd start script out of specific location?


so I have a script that I want to start out of systemd. However, the script needs to be started while being in a specific directory, because some modules cannot find the files in that directory otherwise. So when I start it manually i would do cd and then my directory and then start the script, but I now need to find a way to do this with systemd to start automatically. Help is greatly appreciated, I'm pretty new so still figuring everything out :)


Solution

  • You can try using the WorkingDirectory and ExecStart directives. You will need to provide your own paths here as they’re not stated in your question.

    WorkingDirectory=/home/pi
    ExecStart=/home/pi/launchscript.sh