I run via a systemd timer a shell script that starts some programs (they display some output) and uses echo to provide some feedback.
root@srv ~ [127]# cat /etc/systemd/system/borg.timer
[Unit]
Description=runs borg every hour
[Timer]
OnCalendar=hourly
Persistent=true
[Install]
WantedBy=multi-user.target
root@srv ~# cat /etc/systemd/system/borg.service
[Unit]
Description=borg backup
[Service]
Type=simple
ExecStart=/etc/local/borg.sh
root@srv ~# cat /etc/local/borg.sh
#!/bin/bash
echo "→→→ starting borg backup at $(date)"
# it is OK to move repositories
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
(...)
When starting the script interactively I see both outputs (the program and
echoones) throughjournalctl.When running it via the timer only the program output is displayed.
I understand that the latter is a non-interactive run, but since the program output someone makes its way to journalctl so what not the timer?
Is there a way to make such feedback outputs from the script appear?
Below is a comparison of what is output via systemctl and journalctl when starting the script ad hoc via sytemctl start borg. I now wonder whether the fact that this is a "two-stage" script (bash running borg.sh which itself runs python behind the scenes) could be a reason for the filtered output (just a wild guess)
Output from systemctl:
root@srv ~# systemctl status borg
● borg.service - borg backup
Loaded: loaded (/etc/systemd/system/borg.service; static)
Active: active (running) since Mon 2022-08-08 18:31:54 CEST; 1min 22s ago
TriggeredBy: ● borg.timer
Main PID: 2651152 (borg.sh)
Tasks: 2 (limit: 28688)
Memory: 1.1G
CPU: 54.304s
CGroup: /system.slice/borg.service
├─2651152 /bin/bash /etc/local/borg.sh
└─2651737 /usr/bin/python /usr/bin/borg compact /backup/borg/srv
Aug 08 18:32:46 srv borg.sh[2651687]: Keeping archive (rule: weekly #4): 231d5f07-3453-46a5-a466-b8760196e120 Sun, 2022-07-03 23:00:11 [ab22320beda4d0f4ac247686ad>
Aug 08 18:32:46 srv borg.sh[2651687]: Keeping archive (rule: monthly #1): 3b280578-586f-4f62-80c1-b296aa8982c2 Thu, 2022-06-30 23:00:10 [067e23be4b7e33ec7b87f32603>
Aug 08 18:32:48 srv borg.sh[2651687]: ------------------------------------------------------------------------------
Aug 08 18:32:48 srv borg.sh[2651687]: Original size Compressed size Deduplicated size
Aug 08 18:32:48 srv borg.sh[2651687]: Deleted data: -3.54 GB -1.61 GB -1.33 MB
Aug 08 18:32:48 srv borg.sh[2651687]: All archives: 2.23 TB 1.82 TB 104.85 GB
Aug 08 18:32:48 srv borg.sh[2651687]: Unique chunks Total chunks
Aug 08 18:32:48 srv borg.sh[2651687]: Chunk index: 199025 7333955
Aug 08 18:32:48 srv borg.sh[2651687]: ------------------------------------------------------------------------------
Aug 08 18:32:48 srv borg.sh[2651152]: →→→ compact backup for /backup/borg/srv
Aug 08 18:33:28 srv borg.sh[2651152]: repo: /backup/borg/srv id: 2022-08-08T18:32:00+02:00 hash:
Aug 08 18:33:30 srv borg.sh[2651152]: →→→ ended backup on srv
Aug 08 18:33:30 srv borg.sh[2651152]: →→→ starting backup on outscale
Aug 08 18:33:30 srv borg.sh[2651152]: →→→ create backup for [email protected]:/backup/srv
Aug 08 18:33:32 srv borg.sh[2652145]: M /etc/docker/domotique/data/hass/.storage/hacs.repositories
Aug 08 18:33:32 srv borg.sh[2652145]: M /etc/docker/domotique/data/hass/.storage/auth
The same log lines via journalctl
Aug 08 18:32:46 srv borg.sh[2651687]: Keeping archive (rule: weekly #4): 231d5f07-3453-46a5-a466-b8760196e120 Sun, 2022-07-03 23:00:11 [ab22320beda4d0f4ac247686adb39bd64533d93c9b02172e4299bf5f7e8ceee8]
Aug 08 18:32:46 srv borg.sh[2651687]: Keeping archive (rule: monthly #1): 3b280578-586f-4f62-80c1-b296aa8982c2 Thu, 2022-06-30 23:00:10 [067e23be4b7e33ec7b87f32603d5a05aa5e1f77e6dff17451b3d63db9130cafc]
Aug 08 18:32:48 srv borg.sh[2651687]: ------------------------------------------------------------------------------
Aug 08 18:32:48 srv borg.sh[2651687]: Original size Compressed size Deduplicated size
Aug 08 18:32:48 srv borg.sh[2651687]: Deleted data: -3.54 GB -1.61 GB -1.33 MB
Aug 08 18:32:48 srv borg.sh[2651687]: All archives: 2.23 TB 1.82 TB 104.85 GB
Aug 08 18:32:48 srv borg.sh[2651687]: Unique chunks Total chunks
Aug 08 18:32:48 srv borg.sh[2651687]: Chunk index: 199025 7333955
Aug 08 18:32:48 srv borg.sh[2651687]: ------------------------------------------------------------------------------
Aug 08 18:33:32 srv borg.sh[2652145]: M /etc/docker/domotique/data/hass/.storage/hacs.repositories
Aug 08 18:33:32 srv borg.sh[2652145]: M /etc/docker/domotique/data/hass/.storage/auth
Everything that starts with →→→ (and the repo line I forgot to prefix) come from an echo.
(...)so I'm not sure why your echo output is not showing up. maybe try just adateor removing the fancy unicode characters?systemctlandjournalctlperspectives.