Sample Header Ad - 728x90

Unable to run flatpak independent of the script that started it

3 votes
2 answers
1164 views
I've always successfuly used an ampersand to start an application in the background from within a script. Such background applications seem to be detached from the script that started it, meaning that when I terminate the script, the applications keep running. I now have a script that first starts a number of applications, some of them flatpaks, and then starts an endless while loop to monitor my ip address to check that the vpn is still working.
#!/bin/bash
start application 1 &
start application 2 &
start flatpak application 1 &
start flatpak application 2 &

while true
do
   check ip address
   sleep 180
done
When I terminate the script with ctrl-C, the non-flatpak applications keep running (as expected), but the flatpaks are terminated. This, however, only happens if the script has this while loop: if I remove the while loop, then all applications keep running when I terminate the script, including the flatpaks. So far, I've tried: - calling the applications with the ampersand:
/usr/bin/flatpak run --command=de.manuel_kehl.go-for-it de.manuel_kehl.go-for-it &
- calling the applications with nohup:
nohup /usr/bin/flatpak run --command=de.manuel_kehl.go-for-it de.manuel_kehl.go-for-it &
- calling disown after starting the application
/usr/bin/flatpak run --command=de.manuel_kehl.go-for-it de.manuel_kehl.go-for-it &
disown
None of these approaches help. Can someone explain why this happens? And is there a solution? I would like to keep all applications, including the flatpaks, running when I terminate the script. tnx (using bash on Linux Mint 19.3 MATE)
Asked by wayan (101 rep)
Sep 11, 2022, 09:57 AM
Last activity: May 15, 2025, 07:17 AM