{"id":29938019,"url":"https://github.com/open-technology-foundation/auto-reboot","last_synced_at":"2025-08-02T23:16:35.052Z","repository":{"id":305602821,"uuid":"1003426467","full_name":"Open-Technology-Foundation/auto-reboot","owner":"Open-Technology-Foundation","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-21T03:26:25.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-21T04:08:35.756Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Open-Technology-Foundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T06:14:25.000Z","updated_at":"2025-07-21T03:26:28.000Z","dependencies_parsed_at":"2025-07-21T04:08:37.113Z","dependency_job_id":"02cd7bca-fdde-4a54-ad7e-07cad12a5418","html_url":"https://github.com/Open-Technology-Foundation/auto-reboot","commit_stats":null,"previous_names":["open-technology-foundation/auto-reboot"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Open-Technology-Foundation/auto-reboot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fauto-reboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fauto-reboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fauto-reboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fauto-reboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Open-Technology-Foundation","download_url":"https://codeload.github.com/Open-Technology-Foundation/auto-reboot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fauto-reboot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268470799,"owners_count":24255391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-02T23:16:29.688Z","updated_at":"2025-08-02T23:16:35.000Z","avatar_url":"https://github.com/Open-Technology-Foundation.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# auto-reboot\n\nIntelligent system reboot scheduler with flexible timing and day-of-week restrictions.\n\n## Overview\n\n`auto-reboot` schedules system reboots based on:\n- System update requirements (`/var/run/reboot-required`)\n- Maximum uptime threshold (default: 14 days)\n- Manual force reboot requests\n\n**Key features**: Automatic sudo elevation, systemd timer integration, dry-run safety, schedule management, and syslog audit trails.\n\n## Quick Start\n\n```bash\n# Check if reboot needed (dry run by default)\nauto-reboot\n\n# Schedule reboot if conditions are met\nauto-reboot -N\n\n# Force reboot at 3 AM\nauto-reboot --force-reboot --reboot-time 03:00 -N\n\n# List scheduled reboots\nauto-reboot --list\n\n# Delete all scheduled reboots\nauto-reboot --delete-all\n```\n\n## Installation\n\n```bash\n# Install script and dependencies\nauto-reboot --install\n\n# Manual installation\nsudo cp auto-reboot /usr/local/bin/\nsudo chmod 770 /usr/local/bin/auto-reboot\nsudo chown root:sudo /usr/local/bin/auto-reboot\n```\n\n## Requirements\n\n- Linux with systemd\n- Bash 4.0+\n- systemd-run (systemd-container package)\n- Membership in sudo group or root access\n\n## Command Reference\n\n### Basic Options\n\n| Option | Description |\n|--------|-------------|\n| `-n, --dry-run` | Test mode without executing (default) |\n| `-N, --not-dry-run` | Execute the reboot schedule |\n| `-f, --force-reboot` | Force reboot regardless of conditions |\n| `-h, --help` | Show help message |\n| `-V, --version` | Show version |\n| `-i, --install` | Install to /usr/local/bin |\n\n### Scheduling Options\n\n| Option | Description |\n|--------|-------------|\n| `-m, --max-uptime-days DAYS` | Max uptime before reboot (default: 14) |\n| `-r, --reboot-time HH:MM` | Schedule time (default: 22:00) |\n| `-a, --allowed-days DAYS` | Restrict to specific days |\n\n### Schedule Management\n\n| Option | Description |\n|--------|-------------|\n| `-l, --list` | Show all scheduled reboots |\n| `-d, --delete TIMER` | Delete specific timer |\n| `-D, --delete-all` | Delete all timers (with confirmation) |\n\n## Day Specifications\n\nThe `--allowed-days` option accepts:\n- Short names: `Sun`, `Mon`, `Tue`, `Wed`, `Thu`, `Fri`, `Sat`\n- Full names: `Sunday`, `Monday`, etc.\n- Numbers: `0` (Sunday) through `6` (Saturday)\n- Multiple: `Mon,Wed,Fri` or `1,3,5`\n\n## Examples\n\n### Basic Usage\n\n```bash\n# Check reboot status\nauto-reboot\n# Output:\n# Host: server01\n# Uptime: up 15 days, 3 hours\n# Reboot-required: present\n# Status: Reboot required\n#   - Reason: System updates require reboot\n#   - Reason: Uptime (15 days) exceeds maximum (14 days)\n# Delay: 43200\n# Scheduled: 2025-07-22 22:00:00 WITA\n# auto-reboot: systemd-run: [DRY RUN] Reboot scheduled in 43200 seconds\n# auto-reboot: [DRY RUN] Use 'auto-reboot' with option '-N' to execute\n\n# Actually schedule the reboot\nauto-reboot -N\n```\n\n### Weekend Maintenance\n\n```bash\n# Reboot only on weekends at 3 AM\nauto-reboot --allowed-days Sat,Sun --reboot-time 03:00 -N\n\n# Reboot Sunday night/Monday morning at 1 AM\nauto-reboot --allowed-days Mon --reboot-time 01:00 -N\n```\n\n### Uptime Management\n\n```bash\n# Reboot if uptime exceeds 7 days\nauto-reboot --max-uptime-days 7 -N\n\n# Weekly reboot on Sunday at 4 AM if uptime \u003e 7 days\nauto-reboot -m 7 -r 04:00 -a Sun -N\n```\n\n### Schedule Management\n\n```bash\n# List all scheduled reboots\nauto-reboot --list\n# Output:\n# Active auto-reboot schedules:\n# =============================\n# 1. auto-reboot-1753063354.timer - Scheduled: Mon 2025-07-21 22:00:00 WITA\n# 2. auto-reboot-1753064000.timer - Scheduled: Sun 2025-07-28 03:00:00 WITA\n# =============================\n# Total: 2 scheduled reboot(s)\n\n# Delete specific timer (using ID)\nauto-reboot --delete 1753063354\n\n# Delete all scheduled reboots\nauto-reboot -D\n# Output:\n# Found 2 auto-reboot schedule(s):\n# auto-reboot-1753063354.timer\n# auto-reboot-1753064000.timer\n# \n# Delete all schedules? [y/N] y\n# auto-reboot: Deleting auto-reboot-1753063354.timer...\n# auto-reboot: Successfully deleted auto-reboot-1753063354.timer\n# auto-reboot: Deleting auto-reboot-1753064000.timer...\n# auto-reboot: Successfully deleted auto-reboot-1753064000.timer\n# auto-reboot: Deleted 2 auto-reboot schedule(s).\n```\n\n### Cron Integration\n\n```bash\n# Add to root's crontab\n# Daily check at 11 PM, reboot on Sunday at 4 AM if needed\n0 23 * * * /usr/local/bin/auto-reboot -m 14 -r 04:00 -a Sun -N\n\n# Check every 6 hours, reboot anytime if uptime \u003e 30 days\n0 */6 * * * /usr/local/bin/auto-reboot -m 30 -N\n\n# Weekly forced reboot on Sunday at 3 AM\n0 2 * * 0 /usr/local/bin/auto-reboot -f -r 03:00 -N\n```\n\n### Emergency Scenarios\n\n```bash\n# Force immediate reboot (at next scheduled time)\nauto-reboot --force-reboot -N\n\n# Force reboot in 5 minutes (using custom time)\nauto-reboot -f -r $(date -d \"+5 minutes\" +%H:%M) -N\n\n# Cancel all pending reboots\nauto-reboot --delete-all\n```\n\n## Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `MACHINE_REBOOT_TIME` | Default reboot time | `22:00` |\n| `MACHINE_UPTIME_MAXDAYS` | Default max uptime | `14` |\n\n```bash\n# Set defaults via environment\nexport MACHINE_REBOOT_TIME=\"03:00\"\nexport MACHINE_UPTIME_MAXDAYS=\"7\"\nauto-reboot -N\n```\n\n## Scheduling Logic\n\n1. **No day restrictions**: Schedules for today at specified time, or tomorrow if time has passed\n2. **With day restrictions**: Finds next allowed day within 7 days\n3. **Force reboot**: Ignores all conditions except time/day restrictions\n\n## Logging\n\nAll reboot schedules and deletions are logged to syslog:\n\n```bash\n# View logs\nsudo journalctl -t auto-reboot\n\n# Example log entries:\n# Jul 21 09:28:22 server01 auto-reboot: Scheduling system reboot in 46898s for user admin (uptime: 15d)\n# Jul 21 09:28:34 server01 auto-reboot: Successfully scheduled reboot for 2025-07-21 22:30:12\n# Jul 21 09:46:48 server01 auto-reboot: Deleted scheduled reboot timer: auto-reboot-1753061346.timer by user admin\n```\n\n## Safety Features\n\n- **Dry run by default**: Prevents accidental reboots\n- **Automatic sudo**: Elevates privileges when needed\n- **Confirmation prompts**: For delete-all operations\n- **Audit trail**: Syslog entries for all operations\n- **Validation**: Comprehensive input checking\n- **Timer persistence**: Survives system restarts\n\n## Troubleshooting\n\n```bash\n# Verify systemd-run is available\nwhich systemd-run || auto-reboot --install\n\n# Check systemd status\nsystemctl is-system-running\n\n# List all system timers (including auto-reboot)\nsystemctl list-timers --all | grep auto-reboot\n\n# Check timer details\nsystemctl status auto-reboot-XXXXXX.timer\n\n# View recent logs\njournalctl -t auto-reboot --since \"1 hour ago\"\n```\n\n## Security\n\n- Restricted to root and sudo group members\n- File permissions: 770 (owner: root, group: sudo)\n- All operations logged with username\n- No sensitive data in logs\n\n## License\n\nGPL-3.0 - See [LICENSE](LICENSE) for details.\n\n## Version\n\nCurrent version: 1.0.422","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-technology-foundation%2Fauto-reboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-technology-foundation%2Fauto-reboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-technology-foundation%2Fauto-reboot/lists"}