service Command Reference: Usage & CI Examples
service runs init scripts to start, stop, and query services.
service is a portable wrapper that runs SysV init scripts (and redirects to systemd where present). It is handy in containers and images that ship init scripts but do not boot systemd.
Common flags and usage
- service <name> start|stop|restart: control a service
- service <name> status: show current status
- service --status-all: list known services and state
- Runs /etc/init.d/<name> under the hood
- On systemd hosts it forwards to systemctl
Example
shell
service postgresql start
service postgresql statusIn CI
In a Debian/Ubuntu container without systemd, service postgresql start runs the init script directly and works where systemctl fails. It does not wait for readiness, so still follow it with a probe like pg_isready.
Key takeaways
- service runs SysV init scripts and works without systemd.
- It is the container-friendly way to start a bundled service.
- It does not wait for readiness, so pair it with a probe.
Related guides
systemctl Command Reference: Flags, Usage & CI ExamplesReference for systemctl: start, status, is-active, enable, the no-systemd-in-containers caveat, and a CI exam…
journalctl Command Reference: Flags, Usage & CI ExamplesReference for journalctl: -u, -f, --since, -n, -p, -b, and a CI example that dumps a failing service unit log…
pg_isready Command Reference: Flags, Exit Codes & CI ExamplesReference for pg_isready: -h, -p, -t, -q, the 0/1/2/3 exit codes, and a CI wait loop that blocks until a Post…