I have a one-shot service that calls a script in /usr/
Here my .service file:
[Unit] Description = Start apps After = network.target [Service] Type=simple ExecStart=/usr/start_apps.sh [Install] WantedBy=multi-user.target
My script does somthing like:
cd /home/user/apps # Run apps one at a time in background ./app1 & ./app2 &
Now this appears to try to run these apps, but when I do
pgrep app there is nothing running.
So, I assuemed this is because the service has ended. So I tried a different approach:
cd /home/user/apps # Run app1 in back ground ./app1 & # Run app2 in forground so the service does not stop ./app2
Now this works (pgrep shows me the apps are running) - but when I start the service it never returns I have to do ctrl+c and then I can get back to the bash prompt and the apps are both still running.
What I want is to start the service, have both apps run and then return to the command line all by doing just:
systemctl start my-service.service
What is the best way to do this?
update I am installing my service like this:
systemctl stop my-service.service ... copy the service/script files in place... systemctl daemon-reload systemctl enable my-service.service systemctl start my-service.service
not sure... but it might be relavant?