(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-12-15 23:15:17