| name | background-service-manager |
| description | Create and manage long-running background processes with start/stop/status controls, logging, and monitoring. Use for batch processing jobs, data pipelines, continuous services, or any long-running tasks. |
| type | reference |
| version | 2.0.0 |
| category | operations |
| last_updated | "2026-01-02T00:00:00.000Z" |
| related_skills | ["semantic-search-setup","knowledge-base-builder"] |
| capabilities | [] |
| requires | [] |
| tags | [] |
| scripts_exempt | true |
Background Service Manager
Overview
This skill creates service management scripts for long-running background processes. Includes start/stop controls, PID management, log rotation, status monitoring, and graceful shutdown handling.
Quick Start
- Create service script - Copy the basic template below
- Customize command - Set
SERVICE_CMD to your process
- Make executable -
chmod +x service.sh
- Start service -
./service.sh start
- Monitor -
./service.sh status or ./service.sh logs
#!/bin/bash
SERVICE_NAME="myservice"
PID_FILE="/tmp/${SERVICE_NAME}.pid"
LOG_FILE="/tmp/${SERVICE_NAME}.log"
SERVICE_CMD="python3 ./worker.py"
case "$1" in
start)
nohup $SERVICE_CMD >> "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "Started (PID: $!)"
;;
stop)
[ -f "$PID_FILE" ] && kill $(cat "$PID_FILE") && rm "$PID_FILE"
;;
status)
[ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") 2>/dev/null && ||
;;
*) ;;