Linux上服务的启动,停止和重启

(1)查看所有的服务

[[email protected]:practice] service
Usage: service < option > | --status-all | [ service_name [ command | --full-restart ] ]
[[email protected]:practice] service --status-all
 [ + ]  acpid
 [ - ]  anacron
 [ - ]  apparmor
 [ ? ]  apport
 [ + ]  avahi-daemon
 [ + ]  bluetooth
 [ - ]  brltty
 [ ? ]  console-setup
 [ + ]  cron
 [ + ]  cups
 [ + ]  cups-browsed
 [ - ]  dbus
 [ ? ]  dns-clean
 [ + ]  friendly-recovery
 [ - ]  grub-common
 [ ? ]  irqbalance
 [ + ]  kerneloops
 [ ? ]  killprocs
 [ ? ]  kmod
 [ ? ]  lightdm
 [ ? ]  networking
 [ ? ]  ondemand
 [ ? ]  pppd-dns
 [ - ]  procps
 [ - ]  pulseaudio
 [ ? ]  rc.local
 [ + ]  resolvconf
 [ - ]  rsync
 [ + ]  rsyslog
 [ + ]  saned
 [ ? ]  sendsigs
 [ ? ]  speech-dispatcher
 [ - ]  sudo
 [ ? ]  thermald
 [ - ]  udev
 [ ? ]  umountfs
 [ ? ]  umountnfs.sh
 [ ? ]  umountroot
 [ - ]  unattended-upgrades
 [ - ]  urandom
 [ + ]  vboxadd
 [ + ]  vboxadd-service
 [ - ]  vboxadd-x11
 [ + ]  vpnagentd
 [ - ]  x11-common

可以看出vpnagetd服务是启动起来的。

[[email protected]:practice] ps -elf | grep vpnagentd
5 S root      6716  1553  0  80   0 - 10845 futex_ 21:43 ?        00:00:00 /opt/cisco/anyconnect/bin/vpnagentd
0 S berry     6966  2122  0  80   0 -  1172 pipe_w 21:48 pts/5    00:00:00 grep --color=auto vpnagentd
[[email protected]:practice] ps -elf | grep vpnagentd | grep -v berry
5 S root      6716  1553  0  80   0 - 10845 futex_ 21:43 ?        00:00:00 /opt/cisco/anyconnect/bin/vpnagentd

berry那一条是运行当前命令出现的。
查看当前vpnagentd这个服务所占用的端口号和相关ip地址和pid和服务名称

[[email protected]:practice] sudo netstat -anp | grep 6716
tcp        0      0 127.0.0.1:29754         0.0.0.0:*               LISTEN      6716/vpnagentd
unix  2      [ ]         DGRAM                    75522    6716/vpnagentd  

利用service+服务名称+start/stop/restart对服务进行启动,停止和重启

(1)一种是可以使用service脚本来调度,如:

service 服务名 start

service 服务名 stop

service 服务名 restart

[[email protected]:practice] service vpnagentd status
vpnagentd is stopped
[[email protected]:practice] sudo service vpnagentd start
Starting up Cisco AnyConnect Secure Mobility Client Agent
[[email protected]:practice] service vpnagentd status
vpnagentd (pid 7000) is running
[[email protected]:practice] service vpnagentd restart
Shutting down Cisco AnyConnect Secure Mobility Client Agent
Starting up Cisco AnyConnect Secure Mobility Client Agent
[[email protected]:practice] service vpnagentd status
vpnagentd (pid 7020) is running

(2)一种是直接执行某个服务自己的管理脚本,以vpnagetd服务为例

/etc/init.d/vpnagentd  start

/etc/init.d/vpnagentd stop

/etc/init.d/vpnagentd restart

[[email protected]:practice] service vpnagentd status
vpnagentd (pid 7393) is running
[[email protected]:practice] sudo /etc/init.d/vpnagentd stop
Shutting down Cisco AnyConnect Secure Mobility Client Agent
[[email protected]:practice] service vpnagentd status
vpnagentd is stopped
[[email protected]:practice] sudo /etc/init.d/vpnagentd start
Starting up Cisco AnyConnect Secure Mobility Client Agent
[[email protected]:practice] service vpnagentd status
vpnagentd (pid 7707) is running
[[email protected]:practice] sudo netstat -anp | grep 7707
tcp        0      0 127.0.0.1:29754         0.0.0.0:*               LISTEN      7707/vpnagentd
unix  2      [ ]         DGRAM                    78741    7707/vpnagentd
[[email protected]:practice] 

端口号仍然是29754。

时间: 2024-08-02 21:23:23

Linux上服务的启动,停止和重启的相关文章

CentOS: Make Command not Found and linux xinetd 服务不能启动

在centos 安装编译器 yum -y install gcc automake autoconf libtool make linux xinetd 服务不能启动: [[email protected] xinetd.d]# service xinetd restart xinetd: unrecognized service 安装xinetd 包 [[email protected] ~]# yum -y install xinetd  rpm包安装成功 [[email protected

Linux上制作Window启动盘

Linux上制作Window启动盘 注意: U盘在Linux中的标签(依具体情况而定:执行df查看) U盘 ----- /dev/sdb4 格式化U盘 建立U盘的启动分区 安装关键工具 ms-sys 执行下列命令在U盘上建立MBR分区 ms-sys -w /dev/sdb # 注意:操作 /dev/sdb 而非 /dev/sdb4 复制文件 将预先下载的ISO文件挂载,并将其中的文件复制到U盘 开机选择从U盘启动 现在即可以安装Windows 参考资料 [1].在Linux中做个Windows启

控制Linux下 mono 服务的启动停止

当Window下的服务部署到Linux的时候,我们一般用Mono.service 来启动停止.参数比较多,不太好用.于是有个这个Shell脚本. 用法:moa s1 start #启动           moa s1 stop # 停止   要求有如下的目录结构: /opt/basepath/                     s1/                          sample1.exe #服务1,文件名称不限                     s2/     

linux上wps2019不能启动解决方法

本人linux上的wps2016升级成wps2019后启动不了,双击图标没反应,在命令行输入wps,提示"/lib64/libc.so.6: version `GLIBC_2.18' not found (required by /lib64/libstdc++.so.6)",此为GLIBC版本过低,即wps2019编译时使用了较高版本的glibc,而系统并不支持(可以用strings命令查看下系统中的GLIBC版本strings /lib64/libc.so.6 | grep GLI

linux上应用随机启动

这是个go项目,其他的可以参考. 首先要有个脚本比如demo #!/bin/bash # # etcd This shell script takes care of starting and stopping Etcd # # chkconfig: 2345 80 20 # ### BEGIN INIT INFO # Provides: etcd # Required-Start: $network $syslog # Required-Stop: $network $syslog # Def

linux 上redis的启动口令

1. cd redis /src 2. ./redis.server ../redis.conf 3. ./redis-cli 原文地址:https://www.cnblogs.com/louissica/p/10824733.html

Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务

RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Linux标准组的启动脚本. Systemd是一个Linux操作系统下的系统和服务管理器.它被设计成向后兼容SysV启动脚本,并提供了大量的特性,如开机时平行启动系统服务,按需启动守护进程,支持系统状态快照,或者基于依赖的服务控制逻辑. 先前的使用SysV初始化或Upstart的红帽企业版Linux版本

linux&nbsp;下&nbsp;apache启动、停止、重启命令

原文:linux 下 apache启动.停止.重启命令 基本的操作方法: 本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令: 推荐/usr/local/apache2/bin/apachectl start apaceh启动 apache停止命令 /usr/local/apache2/bin/apachectl stop   停止 apache重新启动命令: /usr/local/apache2/bin/apachectl res

linux下nginx启动停止重启控制脚本

这是控制nginx服务的脚本文件,包括控制nginx的启动.重启.停止.平滑重启.对配置文件的额检查. [[email protected] ~]# cat nginx.sh #!/bin/env bash # description:nginx server   ###必须加描述 # nginx - this script is used to control nginx service # processname nginx # chkconfig: - 85 15 # edit by su