cannot run juju from crontab

I’m trying to use juju commands from the default user crontab but it doesn’t work if the user isn’t logged in . The error is /system.slice/cron.service is not a snap cgroup

my conf: ubuntu@juju:~$ juju --version

3.6.0-genericlinux-amd64

my crontab: ubuntu@juju:~$ crontab -l

SHELL=/usr/bin/bash

*/5 * * * * juju --version >$HOME/juju-version.txt 2>&1

Is there a way to run juju from cron without the user is logged in?

P.S: I found a similar problem and a workaround here: https://forum.snapcraft.io/t/system-slice-cron-service-is-not-a-snap-cgroup/30196

Hey @macchese,

Thanks for reaching out to us. Because of the way cgroups are used in snaps the execution of the juju needs to happen in the same slice as far as I am aware. The best and most modern way to achieve this would be to run juju from within a system timerd unit (https://www.freedesktop.org/software/systemd/man/latest/systemd.timer.html).

Please let us know if we can help constructing what this might look like for a local user.

Cheers tlm

thank you a lot, at the moment I’ve solved using loginctl enable-linger user but It seems to me just a workaroud so I’ll try your tip asap

max