Start script on NFS share (AutoFS)
Hi,
we created a NFS-Share and connected it to the Client with autofs. The NFS-Share contains multiple scripts we want to lauch at startup of RHEL. So we put the commands in the rc.local file.
Sometimes the commands are executed on startup sometimes not.
How can we check if the networkshare is available on startup. I think this is causing the problem. Is there a solution to map the share reliable. Thank you for your help.
Responses
If you have all of your scripts in a mounted filesystem, you could always enable a simple wait with a code-block like:
while [[ $(mountpoint /NFS/MOUNTPOIN)$? -ne 0 ]]
do
sleep 5
done
/NFS/MOUNTPOINT/SCRIPT
What the above does is initiates a wait-state for so long as the NFS filesystem isn't mounted. As soon as the filesystem completes its mount state, it will attempt to execute /NFS/MOUNTPOINT/SCRIPT
Danger of the above is that if you have problems talking to your NFS server, your rc.local will wait-forever. You could play around with using nohup and shell-backgrounding to make it so that the wait/execute occurs in an independent subshell ...but you'd need to ensure that nothing else needs that forked-shell to complete first.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
