When you run systemctl restart mysql
on CentOS 7 and get no output, this is actually the expected behavior of systemd. Unlike the older SysV init system which provided verbose status messages, systemd follows the Unix philosophy of "silence is success" for most operations.
To get similar feedback to what you're used to from CentOS 6, use these commands:
# For restart operations:
systemctl restart mysql.service && systemctl status mysql.service
# For checking current status (detailed output):
systemctl status mysql.service -l
# Alternative format with process info:
systemctl show --property=ActiveState,SubState,ExecMainPID mysql.service
The service mysql restart
redirection message is normal - it's showing you the compatibility layer in action. The old service
command still exists but now calls systemctl
internally.
For more SysV-like behavior, create an alias in your shell:
alias restart='systemctl restart $1 && systemctl status $1'
alias status='systemctl status $1 -l'
Or create a wrapper script at /usr/local/bin/svc
:
#!/bin/bash
if [ "$1" = "status" ]; then
systemctl status "${2}.service" -l
else
systemctl $1 "${2}.service" && systemctl status "${2}.service" -l
fi
When troubleshooting silent failures, always check the journal:
journalctl -u mysql.service -b
journalctl -u mysql.service --since "5 minutes ago"
Systemd intentionally minimizes command-line output because:
- Services are managed as units with rich metadata
- Status can be queried separately from operations
- Modern automation tools expect clean output
When migrating from CentOS 6 to CentOS 7, administrators often encounter behavioral differences in service management. The legacy service
command provided immediate feedback through status codes and output messages, while systemctl
in systemd tends to operate silently by default.
The silent behavior occurs because systemd handles service states differently. Unlike SysV init scripts that output status messages directly, systemd relies on its journal for logging. Here's how to get equivalent feedback:
# For immediate status after operation:
systemctl restart mysql.service && systemctl status mysql.service
# Alternative using --no-pager for cleaner output:
systemctl restart mysql; systemctl status mysql --no-pager
When troubleshooting service operations, these commands provide comprehensive information:
# Check service status with full details
systemctl status mysql.service -l
# View recent journal entries
journalctl -u mysql.service -n 20 --no-pager
# Filter for error messages only
journalctl -u mysql.service -p err -b
The redirection message Redirecting to /bin/systemctl
indicates the legacy compatibility layer. For consistent behavior, consider these alternatives:
# Traditional syntax with output:
service mysql restart --verbose
# Modern equivalent:
systemctl restart mysql.service --no-block --show-transaction
For those missing the old-style output, create a wrapper script:
#!/bin/bash
service=$1
action=$2
systemctl $action $service >/dev/null 2>&1
result=$?
if [ $result -eq 0 ]; then
echo -n "$action $service"
systemctl is-active $service | grep -q '^active$' && echo -e "\t[ OK ]" || echo -e "\t[FAILED]"
else
echo "$action $service failed (code $result)"
journalctl -u $service -n 5 --no-pager
fi
Advanced users can modify systemd's output behavior by creating drop-in configuration files:
# Create configuration override
mkdir -p /etc/systemd/system.conf.d
cat > /etc/systemd/system.conf.d/10-verbose.conf <