CLI to stop only user installed apps

I would like to make a cron job that stops (and starts) all apps, so I can make sure I get a good back up (so that nothing is in use). I found a command that does this but it also kills the TrueNAS Ui, and I assume other things.

What is a good command that stops (and starts) only user installed apps?

What command did you find? Usual advice is to use the middleware and GUI to control items.

I found docker stop $(docker ps -aq)

Again it kills everything.

I can’t use the GUI, I want this to kick off automatically at about 4am, backup the files, then start the apps again.

You should probably take a look at the scale API documententation. There should be an API call to start and stop an app

But that would be through a 3rd party app, no? This should be a simple cron job I’d think. Command or short script?

no you can execute api calls from the shell, so it should be possible to include them in a script, but i have absolutely no idea how since i don’t know how to code.

I do not know much about API to be honest, I am not a fully programmer. I do, however, know (the tiniest) about coding and can muddle through.

I did reach out to Skynet and it’s of little help.

if you go to yourtruenasip/api/docs/ you can see a list of the api calls and i saw one for starting and stopping apps

I will try and look. Starting and stopping them are not hard, I have that down. It’s starting and stopping all of them, without having to name each one.

The answer is this:

sudo docker ps --format ‘{{.Names}}’ | xargs -I {} sudo docker stop {}
sudo docker ps -a --format ‘{{.Names}}’ | xargs -I {} sudo docker start {}