agentleFS
Alex72-pyAlex72-py/termux-elite/skills/termux-services/SKILL.md

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.

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
  1. Very specific:

    Run sh scripts/check-services.sh (read-only).

    line 25
  2. Very specific:

    Only needs to survive a closed terminal session: tmux, screen, or nohup.

    line 28
  3. Very specific:

    Never daemonize or background inside run.

    line 37

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Only needs to survive a closed terminal session: tmux, screen, or nohup. No service needed.
  2. 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 call termux-wake-lock when the job needs the CPU awake.
  3. 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 with sv-enable, sv-disable, and sv up|down|status <name>.
  4. A custom service is a directory with an executable run script. Run in the foreground and send stderr to stdout:
    #!/data/data/com.termux/files/usr/bin/sh
    exec 2>&1
    exec <command> <args>
    Never daemonize or background inside run; the supervisor expects the process to stay in the foreground.
  5. Combine mechanisms deliberately: Termux:Boot can start the service daemon; termux-services supervises the program.
  6. 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 a run script that runs the server in the foreground with exec 2>&1, restarts the session, and proves it with sv status and 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-processes when Android kills Termux itself.
  • termux-sshd when the service is the SSH server.
  • termux-network when the service binds a port that other devices cannot reach.
  • termux-environment for Android level and app sources.

Report

Mechanism chosen and why, files created, how to stop it, and the verification result.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.