简体   繁体   中英

Restart service with custom path to init.d file

I want to restart a service via init.d file on AIX. Ansibles service and sysvinit didn't work. How to control those services using Ansible.

I know I could run a shell command but maybe there is a builtin solution.

This is, what I would do on a shell:

/etc/rc.d/init.d/nrpe restart

From the docs of the service builtin :

Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart.

Basically the service module tries to auto-detect which init system is used and perform the action using that init system. But if your init system does not know about the service (you are running the init script directly, right?) it (the init system) will not be able to restart it.

So you can not use the service module or any other module that tries to interact with your init system, if the init system is not aware of your service.

You should put your init script into the correct directory for your init system to recognize it (then you can also run service nrpe restart ) and then use the service module.
If you can not do that for some reason, you will need to use the command or shell module to restart your service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM