lcfg-service - Call service actions in a platform-independent way
This documentation refers to lcfg-service version 1.20.8
lcfg-service [--timeout seconds] [--debug] service_name action_name args
This script can be used to run service actions in a platform-independent way. A service is typically a daemon, such as httpd, sshd or crond, for which there are various actions which can be applied (e.g. stop, start, status). Historically in the SysVinit era these actions were called by running a script in /etc/init.d
, recently this was done using the service
command and now with Systemd they are executed using systemctl
. It is useful to be able to call an action from a script without needing to encode any knowledge of which system is being used on a particular platform. On LCFG managed systems all the necessary information is already available in the sysinfo component resources. This tool uses the LCFG::Utils::Service module to query the sysinfo information and execute the required command in the appropriate way for the current platform.
The service name (e.g. httpd, sshd, crond) and the action name (e.g. stop, start, status) must both be specified.
This option can be used to set the integer number of seconds to wait for the command to run. If the timeout is exceeded then the script will fail and exit with status 253. The default timeout is 10 minutes.
This option can be used to enable useful debugging messages to be printed to stderr.
This option causes the usage documentation to be printed to the screen.
The configuration for this tool comes from the LCFG sysinfo component resources. They are used to select the correct init-tool (e.g. service or systemctl) for the current platform.
If there is a usage error this script will exit with a status of 254. If there is a error running the command this script will exit with a status of 253. Otherwise, if the command completes the script will exit with the status of the command.
Most of the functionality of this script is provided by the LCFG::Utils::Service module. This script also requires Try::Tiny.
LCFG::Utils::Service, LCFG::SysInfo, lcfg-sysinfo(8)
This is the list of platforms on which we have tested this software. We expect this software to work on any Unix-like platform which is supported by Perl.
ScientificLinux6, EnterpriseLinux7, MacOSX
Please report any bugs or problems (or praise!) to bugs@lcfg.org, feedback and patches are also always very welcome.
Stephen Quinney <squinney@inf.ed.ac.uk>, Paul Anderson <dcspaul@inf.ed.ac.uk>
Copyright (C) 2015 University of Edinburgh. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the terms of the GPL, version 2 or later.