Hi folks, I think this is likely a snapd bug, but just wanted to post on the forum for clarity on the situation.
I have this simple snap which just prints off something every 1 minute:
name: every-1-min
version: '0.1'
summary: every-1-min
description: every-1-min prints something off to the logs every 1 minutes
grade: stable
confinement: strict
apps:
every-1-min:
command: echo "hello"
daemon: oneshot
passthrough:
timer: 00:00-24:00/1440
parts:
my-part:
plugin: nil
And when I install the snap, the service shows up as disabled:
$ sudo snap install --devmode every-1-min_0.1_amd64.snap
every-1-min 0.1 installed
$ snap services
Service Startup Current
every-1-min.every-1-min disabled inactive
However, it’s still running fine:
$ sudo journalctl -ef -u snap.every-1-min.every-1-min.service
-- Logs begin at Thu 2018-09-06 12:58:10 CDT. --
Sep 27 08:38:13 my-computer systemd[1]: Starting Service for snap application every-1-min.every-1-min...
Sep 27 08:38:13 my-computer every-1-min.every-1-min[21791]: hello
Sep 27 08:38:13 my-computer systemd[1]: Started Service for snap application every-1-min.every-1-min.
Sep 27 08:39:05 my-computer systemd[1]: Starting Service for snap application every-1-min.every-1-min...
Sep 27 08:39:06 my-computer every-1-min.every-1-min[21913]: hello
Sep 27 08:39:06 my-computer systemd[1]: Started Service for snap application every-1-min.every-1-min.
The confusion is that I can’t seem to stop this service from continuing to run even with snap stop --disable every-1-min.every-1-min
:
$ sudo snap stop --disable every-1-min.every-1-min
Stopped.
The only way to disable the timer it seems is to disable the entire snap:
$ sudo snap disable every-1-min
every-1-min disabled
Now, as a tangent, I tried changing the daemon: oneshot
to daemon: simple
to see if that changed anything, and it just makes it so that the Starting Service for snap application every-1-min.every-1-min...
line isn’t printed off to the logs anymore when the daemon runs (which makes sense). However I still see the same behavior where I can’t disable just the timer service with snap stop --disable
and need to use snap disable
.
Questions:
- What’s the appropriate value for
daemon
for a service that has a timer? In my case the service is a simple command that gets run and finishes, so I assumedoneshot
, but perhapssimple
is better? Does it matter? - Should the service really show up as “disabled” after installing? I think it shouldn’t. I think it should be “stopped”, i.e.
Startup
->enabled
andCurrent
->inactive
, except during the time in between when the application is started by the timer and when it stops, so for example if the command wassleep 60 & echo "done"
, during the 60 seconds the service was sleepingCurrent
should beactive
. - Should
snap stop --disable
actually disable the timer from running again in the future? I think it should.
Ping @mborzecki