Thanks, Chris; systemd timers were indeed what I was looking for.

I got a cron-like repeating Quadlet service functioning. I'll detail the process below since someone else may find this useful in the future.

Before I do that: I'm still interested in how to interface with the journald logging driver from arbitrary processes inside long-running containers, instead of just the one that's Exec'd in the .container file. Any input would be welcome.

- - - - - - - -

Here's the setup. Worth mentioning that this is all rootless and using systemd user services, so lingering is enabled etc.

~/.config/containers/systemd/temp.container:

  [Unit]
  Description=Temporary test container

  [Container]
  Image=someimage:latest
  ContainerName=temp
  LogDriver=journald
  Exec=python /path/to/script.py


~/.config/systemd/user/temp.timer:

  [Unit]
  Description=Run the temp container every minute

  [Timer]
  OnCalendar=*:0/1
  Persistent=true

  [Install]
  WantedBy=timers.target

By default (i.e. without Unit= under [Timer]), `temp.timer` expects `temp.service` to exist as its target. Generate it from the `temp.container` Quadlet file into `$XDG_RUNTIME_DIR/systemd/generator` by running `systemctl --user daemon-reload`. Repeat whenever you change the Quadlet file.

`systemctl --user start temp.timer` starts the timer. To auto-start it during reboots, `systemctl --user enable temp.timer`.

The timer will show up in `systemctl --user list-timers` when started; with `--all` in case it's enabled but stopped. The process output should show up in `journalctl --user -f`.



On Tuesday, Aug 06, 2024 at 11:09 PM, Chris Evich <cevich@redhat.com> wrote:

I think perhaps what you're reaching for is systemd timers. They can
run whatever command you like (including containers) and since you
already have the journald bits configured the logging part should "just
work".

See:

man systemd.timer

---
Chris Evich (he/him)
Senior Quality Assurance Engineer
If there's a "hard-way", I'm the first one to implement it.
_______________________________________________
Podman mailing list -- podman@lists.podman.io
To unsubscribe send an email to podman-leave@lists.podman.io