Skip to content

Add unattended sync mode plus scheduled daemon runner#93

Draft
Codex wants to merge 2 commits into
mainfrom
codex/add-periodic-sync-feature
Draft

Add unattended sync mode plus scheduled daemon runner#93
Codex wants to merge 2 commits into
mainfrom
codex/add-periodic-sync-feature

Conversation

@Codex

@Codex Codex AI commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

Enabled periodic/non-interactive sync to keep SSH keys in sync without prompts. The new sync and daemon commands run uploads/downloads safely in unattended contexts, skipping conflicts instead of blocking.

  • Non-interactive safety: Upload/download/sync accept --non-interactive/--quiet (or auto when stdin isn’t a TTY); conflicting local/server files are skipped with stderr notes; local-only files are left untouched.
  • Sync workflow: New sync command runs upload then download in one shot; safe-mode and path flags are respected.
  • Daemon scheduling: New daemon command loops sync on a configurable interval (default 1h), exiting cleanly on SIGINT/SIGTERM; defaults to non-interactive.
  • Docs/tests: README documents sync/daemon usage; added coverage for non-interactive skip behavior.

Example:

# Hourly unattended reconciliation
ssh-sync daemon --interval 1h --non-interactive
Original prompt

This section details on the original issue you should resolve

<issue_title>Periodic/automatic sync — schedule or daemon mode</issue_title>
<issue_description>## Overview

Allow ssh-sync to automatically run a sync on a recurring schedule so users don't have to remember to run ssh-sync sync manually.

This builds on top of the sync command proposed in #90.

Motivation

SSH keys change infrequently but the consequences of being out of sync (e.g. a key missing on a new machine, or a revoked key still present locally) can be serious. Automating periodic sync removes the manual burden and keeps all machines consistent.

Proposed approaches

Option A — OS-level scheduling (recommended for initial implementation)

Provide a helper command that installs the appropriate scheduler entry for the current platform:

ssh-sync schedule install   # installs cron/launchd/systemd unit
ssh-sync schedule remove    # removes it
ssh-sync schedule status    # shows current schedule

Platform targets:

  • Linux: systemd user timer (~/.config/systemd/user/ssh-sync.{service,timer}) or a crontab entry
  • macOS: launchd plist (~/Library/LaunchAgents/com.github.therealpaulgg.ssh-sync.plist)
  • Windows: Task Scheduler via schtasks

The schedule interval should be configurable (default: every hour). The generated unit/plist/task should run ssh-sync sync non-interactively — which implies the sync command must handle the case where stdin is not a TTY (skip prompts, or adopt a safe default such as skipping rather than deleting on conflict).

Option B — Built-in daemon mode

Add a ssh-sync daemon sub-command that blocks and triggers a sync on a configurable interval using a Go ticker:

ssh-sync daemon --interval 1h

This is simpler to implement cross-platform but requires the process to stay running (e.g. managed by systemd/launchd anyway).

Non-interactive sync considerations

When running unattended (no TTY), the sync command must not hang waiting for user input. Suggested behaviour:

  • If a server key is newer than the local key → skip (do not overwrite)
  • If a local key is absent from the server → skip deletion (keep the local key)
  • Log all skipped conflicts to stderr / a log file so the user can review them later

A --non-interactive / --quiet flag on sync (or auto-detected via term.IsTerminal) would control this path.

Related

Comments on the Issue (you are @codex[agent] in this section)

@therealpaulgg Possible inspo? Or maybe we can do better? https://blog.atuin.sh/atuin-v18-3-0/

@Codex Codex AI changed the title [WIP] Add periodic automatic sync for ssh-sync Add unattended sync mode plus scheduled daemon runner Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Periodic/automatic sync — schedule or daemon mode

2 participants