Add RemainAfterElapse=no to one-time timers
One-time timers now auto-unload from systemd after firing, so they no longer linger as "elapsed" in list-timers. Unit files remain on disk for ID/edit/status lookups; -C still cleans those up. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
456111627d
commit
ba875ac272
1 changed files with 15 additions and 6 deletions
19
systab
19
systab
|
|
@ -294,7 +294,10 @@ OnCalendar=$time_spec
|
|||
EOF
|
||||
|
||||
if ! is_recurring "$opt_time"; then
|
||||
echo "Persistent=false" >> "$timer_file"
|
||||
cat >> "$timer_file" <<'ONETIME'
|
||||
Persistent=false
|
||||
RemainAfterElapse=no
|
||||
ONETIME
|
||||
fi
|
||||
|
||||
cat >> "$timer_file" <<EOF
|
||||
|
|
@ -354,7 +357,10 @@ OnCalendar=$schedule
|
|||
EOF
|
||||
|
||||
if ! is_recurring "$schedule"; then
|
||||
echo "Persistent=false" >> "$SYSTEMD_USER_DIR/${job_name}.timer"
|
||||
cat >> "$SYSTEMD_USER_DIR/${job_name}.timer" <<'ONETIME'
|
||||
Persistent=false
|
||||
RemainAfterElapse=no
|
||||
ONETIME
|
||||
fi
|
||||
|
||||
cat >> "$SYSTEMD_USER_DIR/${job_name}.timer" <<EOF
|
||||
|
|
@ -512,11 +518,14 @@ HEADER
|
|||
if [[ "$old_sched" != "$new_sched" && -f "$timer_file" ]]; then
|
||||
sed -i "s|^OnCalendar=.*|OnCalendar=$new_sched|" "$timer_file"
|
||||
|
||||
# Update Persistent line based on new schedule
|
||||
# Update one-time vs recurring settings
|
||||
if is_recurring "$new_sched"; then
|
||||
sed -i '/^Persistent=false$/d' "$timer_file"
|
||||
elif ! grep -q "^Persistent=false" "$timer_file"; then
|
||||
sed -i "/^OnCalendar=/a Persistent=false" "$timer_file"
|
||||
sed -i '/^RemainAfterElapse=no$/d' "$timer_file"
|
||||
else
|
||||
if ! grep -q "^Persistent=false" "$timer_file"; then
|
||||
sed -i "/^OnCalendar=/a Persistent=false\nRemainAfterElapse=no" "$timer_file"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue