Alex72-py/termux-elite / skills/termux-services
termux-services
VerifiedChoose how to keep a program running on Termux (tmux or nohup, Termux:Boot, or termux-services with runit) and set it up with supervision and logs. Use when a server must restart after a crash, start at boot or app launch, or survive closing the terminal. Do NOT use when the process is being killed by Android (see background-processes first) or for one-off foreground commands.
Termux Services
Purpose
Pick the lightest mechanism that matches the requirement (survive a closed terminal, start at boot, or be supervised and restarted) instead of defaulting to the heaviest.
When to use
- A server or worker must keep running after the terminal closes.
- It must start when the phone boots or Termux launches.
- It must restart after a crash and keep logs.
When NOT to use
- The process is being killed by Android: start with
background-processes; a supervisor cannot outlive a killed Termux app. - One-off foreground commands.
Preconditions
Run sh scripts/check-services.sh (read-only). Know the exact command, working directory, port, and whether it needs the network or a wake lock.
Decision tree
- Only needs to survive a closed terminal session:
tmux,screen, ornohup. No service needed. - Needs to start at device boot or app start: Termux:Boot, a separate app from the same distribution source as Termux. It must be opened once. Scripts go in
~/.termux/boot/, must be executable, and should calltermux-wake-lockwhen the job needs the CPU awake. - Needs supervision, restart on crash, or logs:
termux-services(runit). After installing the package, restart the Termux session so the service daemon starts. Services live under$PREFIX/var/service/<name>; manage them withsv-enable,sv-disable, andsv up|down|status <name>. - A custom service is a directory with an executable
runscript. Run in the foreground and send stderr to stdout:
Never daemonize or background inside#!/data/data/com.termux/files/usr/bin/sh exec 2>&1 exec <command> <args>run; the supervisor expects the process to stay in the foreground. - Combine mechanisms deliberately: Termux:Boot can start the service daemon;
termux-servicessupervises the program. - Boot-time behavior depends on battery optimization for both apps and on the vendor. Verify by rebooting, not by reasoning.
Example
- Situation: A Node server must survive closing Termux and restart after a crash.
- Without the skill: Starts it with
nohup node server.js &, which never restarts and loses logs. - With the skill: Picks
termux-services, writes arunscript that runs the server in the foreground withexec 2>&1, restarts the session, and proves it withsv statusand a kill-and-restart test.
Safety
Enabling a service or boot script starts code unattended and can drain battery or open a network port. State what will run, with which arguments, on which port, and confirm. Never put secrets in a run script; read them from a file with restricted mode.
Verification
sv status <name> shows run, the process responds on its port or check, and after killing the process once the supervisor restarts it. For boot scripts, reboot and re-check.
Rollback
sv-disable <name>, remove the service directory or boot script that was created, and release any wake lock.
Handoffs
background-processeswhen Android kills Termux itself.termux-sshdwhen the service is the SSH server.termux-networkwhen the service binds a port that other devices cannot reach.termux-environmentfor Android level and app sources.
Report
Mechanism chosen and why, files created, how to stop it, and the verification result.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |