Search code examples
unixscriptingsystemd

Systemctl starting multiple commands


I'm trying to use systemctl to start 2 programs with one service (if that's what you call them). They're both python scripts, I tried the:

[service]
Type=simple
ExecStart=/usr/bin/python %i

In the service file. when I run

systemctl start security@/home/pi/pythonProject/p1.py security@/home/pi/pythonProject/p2.py

it fails to start it, and the error code says it tried to start

security@-home-pi-pythonProject-p1.py

And same for p2.py . Can anyone offer any assistance for this?


Solution

  • First, you need to fix [service] to [Service]. That is a syntax error. Second, you need to fix %i to %f. systemd escapes / in instance name to -. %f can get unescaped instance name.

    More detail.