Skip to content

Commit 2a6b0c0

Browse files
display systemd timer status in a nicer way
also display log >= "warning" instead of "err"
1 parent 641dc91 commit 2a6b0c0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

schedule/schedule_systemd.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func (j *Job) createSystemdJob(unitType systemd.UnitType) error {
7171
if err != nil {
7272
return err
7373
}
74+
fmt.Println("")
7475
// display a status after starting it
7576
_ = runSystemctlCommand(timerName, commandStatus, unitType)
7677

@@ -134,7 +135,25 @@ func (j *Job) displaySystemdStatus(command string) error {
134135
return runSystemctlCommand(timerName, commandStatus, systemd.UserUnit)
135136
}
136137

138+
// displaySystemdStatus displays the status of all the timers installed on that profile
139+
func displaySystemdStatus(profile string) error {
140+
timerName := fmt.Sprintf("resticprofile-*@profile-%s.timer", profile)
141+
args := []string{"list-timers", "--all", "--no-pager", timerName}
142+
// if unitType == systemd.UserUnit {
143+
// args = append(args, flagUserUnit)
144+
// }
145+
cmd := exec.Command(systemctlBin, args...)
146+
cmd.Stdout = os.Stdout
147+
cmd.Stderr = os.Stderr
148+
err := cmd.Run()
149+
fmt.Println("")
150+
return err
151+
}
152+
137153
func runSystemctlCommand(timerName, command string, unitType systemd.UnitType) error {
154+
if command == commandStatus {
155+
fmt.Print("Systemd timer status\n=====================\n")
156+
}
138157
args := make([]string, 0, 3)
139158
if unitType == systemd.UserUnit {
140159
args = append(args, flagUserUnit)
@@ -158,8 +177,9 @@ func runSystemctlCommand(timerName, command string, unitType systemd.UnitType) e
158177
}
159178

160179
func runJournalCtlCommand(timerName string, unitType systemd.UnitType) error {
180+
fmt.Print("Recent log (>= warning in the last month)\n==========================================\n")
161181
timerName = strings.TrimSuffix(timerName, ".timer")
162-
args := []string{"--since", "1 month ago", "--no-pager", "--priority", "err", "--unit", timerName}
182+
args := []string{"--since", "1 month ago", "--no-pager", "--priority", "warning", "--unit", timerName}
163183
if unitType == systemd.UserUnit {
164184
args = append(args, flagUserUnit)
165185
}

0 commit comments

Comments
 (0)