Rex::Commands::Service - Online Linux Manual PageSection : 3
Updated : 2021-03-06
Source : perl v5.32.1
Note : User Contributed Perl Documentation
NAMERex::Commands::Service − Manage System Services
DESCRIPTIONWith this module you can manage Linux services.
SYNOPSIS use Rex::Commands::Service
service apache2 => "start";
service apache2 => "stop";
service apache2 => "restart";
service apache2 => "status";
service apache2 => "reload";
service apache2 => "ensure", "started";
service apache2 => "ensure", "stopped";
EXPORTED FUNCTIONS
service($service, $action, [$option])The service function accepts 2 parameters. The first is the service name and the second the action you want to perform. starting a service task "start−service", "server01", sub {
service apache2 => "start";
};
stopping a service task "stop−service", "server01", sub {
service apache2 => "stop";
};
restarting a service task "restart−service", "server01", sub {
service apache2 => "restart";
};
checking status of a service task "status−service", "server01", sub {
if( service apache2 => "status" ) {
say "Apache2 is running";
}
else {
say "Apache2 is not running";
}
};
reloading a service task "reload−service", "server01", sub {
service apache2 => "reload";
};
ensure that a service will started at boot time task "prepare", sub {
service "apache2",
ensure => "started";
};
ensure that a service will NOT be started. task "prepare", sub {
service "apache2",
ensure => "stopped";
};
If you need to define a custom command for start, stop, restart, reload or status you can do this with the corresponding options. task "prepare", sub {
service "apache2",
ensure => "started",
start => "/usr/local/bin/httpd −f /etc/my/httpd.conf",
stop => "killall httpd",
status => "ps −efww | grep httpd",
restart => "killall httpd && /usr/local/bin/httpd −f /etc/my/httpd.conf",
reload => "killall httpd && /usr/local/bin/httpd −f /etc/my/httpd.conf";
};
This function supports the following hooks: before_${action} For example: before_start, before_stop, before_restart This gets executed right before the given service action. All original parameters are passed to it. after_${action} For example: after_start, after_stop, after_restart This gets executed right after the given service action. All original parameters, and any returned results are passed to it.
service_provider_for $os => $type;To set another service provider as the default, use this function. user "root";
group "db" => "db[01..10]";
service_provider_for SunOS => "svcadm";
task "start", group => "db", sub {
service ssh => "restart";
};
This example will restart the ssh service via svcadm (but only on SunOS, on other operating systems it will use the default). 0
Johanes Gumabo
Data Size : 14,082 byte
man-Rex::Commands::Service.3pmBuild : 2024-12-29, 07:25 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 255,710
Visitor ID : :
Visitor IP : 18.191.174.4 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.29
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|252|Rex::Commands::Service.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Rex::Commands::Service.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|252|Rex::Commands::Service.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Rex::Commands::Service.3pm|43|'br══─}─══ |'br══─}─══
)