1

I want the main command of the service (ExecStart) to run in a WorkingDirectory that may not exist on the first run of the service. I added a mkdir in the ExecStartPre, but it seems the mkdir itself is started in the same working directory that doesn't exists and fails. Also tried playing with the + and - flags, with no success so far.

Found a duplicate here, but no answer.

Another duplicate was suggested. The answers are basically:

  • Create a helper unit that will create the directory for the main unit
  • Create an entry in tmpfiles.d

Thanks for pointing these solutions. There are probably other solutions too. I was wondering if it was possible to create the directory from the service's configuration file, without having to rely on an external mechanism. This would make deployment easier for me. Sorry for not being specific enough.

Antoine
  • 281
  • 1
  • 3
  • 12
  • 1
    Does this answer your question? [Create a directory under /var/run at boot](https://serverfault.com/questions/779634/create-a-directory-under-var-run-at-boot) – Gerald Schneider Sep 15 '22 at 06:58
  • @GeraldSchneider thanks. While technically some of these solutions create the directory, I was looking to create it directly from the unit file (because of deployment considerations) – Antoine Sep 27 '22 at 12:39

0 Answers0