RHEL / CentOS: Shell Script Wrapper TO Start / Stop / Restart NFSv4 Services In A Particular Order

in Categories Automation & Management, Networking last updated September 5, 2016

A simple shell script wrapper to start / stop / restart NFSv4 service on CentOS / RHEL v.6.x server in a particular order. This script also demonstrates how to use the ln command to create soft links to the same script and take a different action as per $0.

How do I use this script?

Download and install the script nfs.rc in ~/bin/:
chmod +x nfs.rc
ln -s nfs.rc nfs.server
ln -s nfs.rc nfs.client

To start / stop / restart nfsv4 server services in a single go:
# ~/bin/nfs.server stop
# ~/bin/nfs.server status
# ~/bin/nfs.server start
# ~/bin/nfs.server restart

To start / stop / restart nfsv4 clients in a single go, enter:
# ~/bin/nfs.client stop
# ~/bin/nfs.client start
# ~/bin/nfs.client restart
# ~/bin/nfs.client status

Sample outputs:

Share this on: