0

I want to set target to service in CentOS7 (Systemd). I want to know following.

  • How to set target to service.
  • How to show target of service.

In other words, I want to know substitution for following commands.

$ sudo chkconfig --level=2345 mysql on (<- set runlevel)
$ chkconfig --list mysql (<- show runlevel)

I understood that "runlevel" in CentOS6 changed "target" in CentOS7and I should use "systemctl" command.

But problems were not solved.

I heard that following command is replacement for "chkconfig --list" , but I can't check target and can't set target.

systemctl list-unit-files
Taiju Aoki
  • 13
  • 2
  • Welcome to StackOverflow. Questions about systemd are better suited to http://serverfault.com or unix.stackexchange.com/questions/tagged/systemd Questions on SO are expected to be directly about programming. – Mark Stosberg May 20 '16 at 17:30
  • Mark Stosberg Thank you! – Taiju Aoki May 22 '16 at 05:47

1 Answers1

0

Setting the target is done in the unit file for the service. For example:

[Install]
WantedBy=multi-user.target

Then you run systemctl enable $service_name to create a symlink which enables the service to start as part of a particular target. You could also create the symlinks manually. The enable command will print out the paths of the symlinks it's creating.

I think systemctl --reverse list-dependencies $service is the way to find what services and targets depend on a specific services to boot.

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49