termux-services). This allows it to run continuously without requiring an active terminal session.
Service Commands
Thesv command is used to control the OpenClaw service. All commands follow the pattern sv <action> openclaw.
Check Service Status
View the current state of the OpenClaw service:Start the Service
Start OpenClaw if it’s not running:Stop the Service
Gracefully stop the OpenClaw service:Restart the Service
Restart OpenClaw (useful after configuration changes):Viewing Logs
Service logs are managed bysvlogd and stored in a rotating format. To view real-time logs:
Understanding Service States
Thesv status command can return several states:
- run: Service is running normally
- down: Service is stopped
- finish: Service completed execution
- fail: Service encountered an error and stopped
Keeping the Service Alive
Android’s aggressive battery optimization can kill background processes when Termux is minimized. To prevent this:What Happens When Termux is Closed
Withtermux-wake-lock active:
- OpenClaw continues running in the background
- The service remains accessible via the web UI
- All automation and workflows continue executing
- Android may kill the Termux process after a few minutes
- The OpenClaw service will stop
- You’ll need to reopen Termux and restart the service
Disabling Wake Lock
If you need to release the wake lock:Service Configuration
The service is defined by two run scripts: Main Service ($PREFIX/var/service/openclaw/run):
- Sets required environment variables (
PATH,TMPDIR) - Starts the OpenClaw gateway using
openclaw gateway
$PREFIX/var/service/openclaw/log/run):
- Manages log rotation and timestamping
- Writes to
$PREFIX/var/log/openclaw/
These scripts are created automatically during installation. Manual modification is generally not needed unless you’re troubleshooting or customizing the setup.
Common Issues
Service Won’t Start
-
Check if the service directory exists:
-
Verify environment variables are set:
-
Check for errors in logs:
Service Keeps Stopping
- Ensure
termux-wake-lockis active - Check logs for crash messages
- Verify that onboarding was completed successfully