termux-services
Skill2 starsChanged 57 days agoMITView on GitHub
Choose 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.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- background-processesSkill
- git-credentialsSkill
- github-actionsSkill
- node-native-buildSkill
- package-troubleshootingSkill
- proot-boundariesSkill
- python-native-buildSkill
- storage-permissionsSkill
- termux-adbSkill
- termux-apiSkill
- termux-backupSkill
- termux-environmentSkill
- termux-networkSkill
- termux-sshdSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Run sh scripts/check-services.sh (read-only).
- Very specific: line 28
Only needs to survive a closed terminal session: tmux, screen, or nohup.
- Very specific: line 37
Never daemonize or background inside run.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

