Service Management: Difference between revisions
m Text replacement - "<code>" to "{{code|" |
|||
| Line 9: | Line 9: | ||
service <service> restart | service <service> restart | ||
Since the location of startup scripts varies from distro to distro, using the | Since the location of startup scripts varies from distro to distro, using the {{code|service</code> command is recommended. | ||
| Line 35: | Line 35: | ||
== FreeBSD == | == FreeBSD == | ||
Similar to linux, you can either start services using their startup scripts or using the | Similar to linux, you can either start services using their startup scripts or using the {{code|service</code> command. | ||
Usually, the startup scripts are located in | Usually, the startup scripts are located in {{code|/etc/rc.d</code> | ||
/etc/rc.d/<service> restart | /etc/rc.d/<service> restart | ||
However, if it is 3rd party software, they are located in | However, if it is 3rd party software, they are located in {{code|/usr/local/etc/rc.d</code> | ||
/usr/local/etc/rc.d/<service> restart | /usr/local/etc/rc.d/<service> restart | ||
Or to not worry about any of the above, use | Or to not worry about any of the above, use {{code|service</code> | ||
service nfs stop | service nfs stop | ||
service sickbeard start | service sickbeard start | ||
| Line 49: | Line 49: | ||
<strong>Note:</strong> You can send the | <strong>Note:</strong> You can send the {{code|HUP</code> signal to restart a service. For instance, to restart NFS, you can do any one of: | ||
kill -HUP `cat /var/run/mountd.pid` | kill -HUP `cat /var/run/mountd.pid` | ||
/etc/rc.d/nsfd restart | /etc/rc.d/nsfd restart | ||
| Line 55: | Line 55: | ||
== Solaris / SunOS == | == Solaris / SunOS == | ||
The startup scripts are located in | The startup scripts are located in {{code|/lib/svc/method/<service></code> | ||
/lib/svc/method/<service> restart | /lib/svc/method/<service> restart | ||
svcadm restart <service> | svcadm restart <service> | ||
Revision as of 19:13, 24 February 2017
Linux (using system v)
Starting & Stopping Services
Use any one of:
/etc/init.d/<service> restart
/etc/init.d/<service> stop && /etc/init.d/<service> start
service <service> restart
Since the location of startup scripts varies from distro to distro, using the {{code|service command is recommended.
Manage Startup
Show all the services for every runlevel:
chkconfig --list
Enable a service (eg: sshd) on runlevels 2, 3, 4:
chkconfig --add sshd chkconfig --level 234 sshd on
Linux (using systemd)
Starting & Stopping Services
systemctl start systemctl stop
Getting Service Information
systemctl status
Enabling / Disabling Services at Startup
systemctl enable systemctl disable
FreeBSD
Similar to linux, you can either start services using their startup scripts or using the {{code|service command.
Usually, the startup scripts are located in {{code|/etc/rc.d
/etc/rc.d/<service> restart
However, if it is 3rd party software, they are located in {{code|/usr/local/etc/rc.d
/usr/local/etc/rc.d/<service> restart
Or to not worry about any of the above, use {{code|service
service nfs stop service sickbeard start service httpd status
Note: You can send the {{code|HUP signal to restart a service. For instance, to restart NFS, you can do any one of:
kill -HUP `cat /var/run/mountd.pid` /etc/rc.d/nsfd restart service nfs restart
Solaris / SunOS
The startup scripts are located in {{code|/lib/svc/method/<service>
/lib/svc/method/<service> restart svcadm restart <service>
Example: To restart ssh, do any one of:
svcadm restart ssh
svcadm restart svc:/network/ssh
/lib/svc/method/sshd restart