使用service命令管理linux服务

使用service命令管理linux服务:

我们来看一下service的manual:

DESCRIPTION
       service  runs  a System V init script or upstart job in as predictable environment as possi‐
       ble, removing most environment variables and with current working directory set to /.

The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT, or the
       name  of  an upstart job in /etc/init. The existence of an upstart job of the same name as a
       script in /etc/init.d will cause the upstart job to take precedence over the init.d  script.
       The  supported  values  of  COMMAND depend on the invoked script, service passes COMMAND and
       OPTIONS to the init script unmodified. For upstart jobs, start,  stop,  status,  are  passed
       through to their upstart equivilents. Restart will call the upstart ‘stop‘ for the job, fol‐
       lowed immediately by the ‘start‘, and will exit with the return code of the  start  command.
       All scripts should support at least the start and stop commands.  As a special case, if COM‐
       MAND is --full-restart, the script is run twice, first with the stop command, then with  the
       start command. This option has no effect on upstart jobs.

service  --status-all runs all init scripts, in alphabetical order, with the status command.
       This option only calls status for sysvinit jobs, upstart jobs can be queried  in  a  similar
       manner with initctl list‘.
它用到的文件在/etc/init.d和/etc/init目录下,它至少包括start和stop两个命令,上文提到了upstart,我专门查了一下,解释如下:

Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.

以上两个目录下是一些shell脚本

当然也可以不用service服务,直接调用/etc/init.d/xxx start和/etc/init.d/xxx stop

原文地址:https://www.cnblogs.com/live-program/p/11057928.html

时间: 2024-07-31 01:10:27

使用service命令管理linux服务的相关文章

Zabbix源码安装,使用service命令管理zabbix进程

1.       前期环境: Zabbix源代码解压包:/root/zabbix-3.0.27 Zabbix安装路径:/usr/local/zabbix-3.0.27 2.       复制启动脚本到/etc/init.d/目录下 启动脚本:/root/zabbix-3.0.27/misc/init.d/fedora/core cp zabbix_agentd /etc/init.d/ cp zabbix_server /etc/init.d/ 3.       按照实际情况修改启动脚本参数 V

Linux - 利用systemctl命令管理服务

systemctl命令是系统服务管理器指令,融合了service和chkconfig的功能,可以查看和设置服务. 这里以docker服务为例. 利用systemctl命令管理 显示服务状态:systemctl status docker.service 列出服务层级和依赖关系:systemctl list-dependencies docker.service 启动服务:systemctl start docker.service 关闭服务:systemctl stop docker.servi

用service命令和chkconfig命令管理服务进程

service命令可以快速地开启和停止linux中的服务程序,这在调试过程中非常有用.chkconfig命令可以快速地设置开机时需要自动启动的服务程序. 这两个命令的功能都可以通过其他方法实现,只不过有了它们之后更加方便,维护工作可以更加轻松. service命令和进程管理脚本 在debian linux中如果用apt-get命令安装mysql,nginx等服务程序,安装程序都会自动在/etc/init.d/目录中创建一个管理此服务进程用的shell脚本,如: /etc/init.d/mysql

Linux学习笔记(19) Linux服务管理

1. 服务的分类 Linux服务可分为RPM包默认安装的服务和源码包安装的服务.前者可细分为独立的服务(直接作用于内存中)和基于xinetd服务.xinetd本身是独立的服务,其唯一的功能是管理其他服务.优点是管理的服务不占用内存,缺点是响应缓慢. (1) 启动和自启动 服务启动就是在当前系统中让服务运行,并提供其功能.服务的自启动是指让服务在系统开机或重启之后,随着系统的启动而自动启动服务. (2) 查询已安装的服务 RPM包安装的服务可通过chkconfig --list命令查看,其作用是查

[转]玩转Windows服务系列——命令行管理Windows服务

本文转自:http://www.cnblogs.com/hbccdf/p/managewindowsservicewithcmd.html 说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令,命令行都是非常方便以及强大的工具. 接下来就看一下如何通过cmd命令管理Windows服务. 管理Windows服务的主要cmd命令 管理Windows服务的命令应该有很多,但是我所了解到的命令主要有两个:sc.net. 说是

linux 服务简介

Linux服务(Linux services)对于每个应用Linux的用户来说都很重要.关闭不需要的服务,可以让Linux运行的更高效,但并不是所有的Linux服务都可以关闭.今天安装了一次CentOs Linux,发现Linux启动的时候启动了好多服务,大部分都不知道是干什么的.因此着重了解了一下那些Linux服务(Linux services)可以关闭,那些Linux服务(Linux services)不能随意关闭. 在关闭Linux服务之前,需要了解一些概念: 什么是Linux服务/后台进

如何使用PowerShell管理Windows服务

[TechTarget中国原创] 作为一名系统管理员,最常见的任务之一就是学会管理Windows服务,这是保证Windows服务器和客户端正常运行的重要内容. 许多操作系统和应用程序都依赖于这些服务. Microsoft Management Console窗口是我们非常熟悉的一款Windows服务,通过该服务,管理员可以在本地或者远程计算机上操控服务.但是,一时间还不能改变几十台甚至几百台机器. 此时,PowerShell就派上用场了. PowerShell应用几个本地Cmdlet来管理Win

Linux 服务分类

一,服务分类 1,服务简介与分类 1,服务的分类 启动与自启动 1,服务启动:就是在当前系统中让服务运行,并提供功能 2,服务自启动:自启动是指让服务在系统开机或重启动之后,随着系统的启动而自动启动的服务 查询已安装的服务: 1,RPM包安装的服务 chkconfig --list 查看服务自启动状态,可以看到所有RPM包安装的服务 2,源码包安装的服务 查看服务安装位置,一般是/usr/local下 ps -aux 查看进程 RPM安装服务和源码包安装服务的区别: RPM安装服务和源码包安装服

用于管理Linux系统中的各种服务的命令service命令

我们知道service命令是用于管理Linux系统中的各种服务的命令.其实service是位于系统中/usr/sbin/service的一个可执行的脚本,其内容如下: #!/bin/sh ########################################################################### # /usr/bin/service # # A convenient wrapper for the /etc/init.d init scripts.  #