CentOS 7 systemctl - no feedback or status/output
I just installed CentOS 7.1 on one server and I'm confused by how systemctl
works compared to service
.
On CentOS 6, I would get feedback when running service
, such as:
root@centos6 [~]# service mysql restart
Shutting down MySQL........................................[ OK ]
Starting MySQL.............................................[ OK ]
root@centos6 [~]# service mysql status
MySQL running (910285) [ OK ]
root@centos6 [~]#
However on CentOS 7, when I use systemctl
, I get nothing. I don't know what happened, or if something even happened:
root@centos7 [~]# systemctl restart mysql
root@centos7 [~]# /bin/systemctl restart mysql.service
# Nothing happened
And when I run service
on CentOS 7, this happens:
root@centos7 [~]# service mysql restart
Redirecting to /bin/systemctl restart mysql.service
What am I'm missing?
Solution 1:
Here is what I do:
systemctl start my-service && journalctl -fexu my-service
journalctl
is the simplest way to get output from your systemd services.
-
-f
follows the log output ofmy-service
until I quit (ctrl-C). -
-e
scrolls to the end (most recent) log messages. -
-x
explanations from the Journal Message Catalog, if available.
(See also https://www.freedesktop.org/wiki/Software/systemd/catalog/) -
-u
will only show logs from themy-service
unit.
Solution 2:
Like any good unix command, systemctl
outputs nothing unless there was a problem, or you ran a command that explicitly requires output. If you see nothing, then the command was successful.
If you wish, you can run systemctl status mysql
to see its current status.