I am very new to Linux Shell Scripting and was wondering if anyone could help me with the following.
I created a script to synch time with my linux machine but only one exec command seems to complete
#!/bin/bash
#Director SMS Synch Time Script
echo The current date and time is:
date
echo
echo Synching GTS Cluster 1 directors with SMS.
echo
echo Changing date and time for director-1-1-A
exec ssh [email protected] "ntpd -q -g"
echo Finished synching director-1-1-A
echo
sleep 2
echo Changing date and time for director-1-1-B
exec ssh [email protected] "ntp -q -g"
echo Finished synching director-1-1-B
echo
sleep 2
echo Finished Synching GTS Cluster 1 directors with SMS.
sleep 2
echo
echo Synching SVT Cluster 2 directors with SMS.
echo
echo Changing date and time for director-2-1-A
exec ssh [email protected] "ntpd -q -g"
echo Finished synching director-2-1-A
echo
sleep 2
echo Changing date and time for director-2-1-B
exec ssh [email protected] "ntpd -q -g"
echo Finished synching director-2-1-B
echo
sleep 2
echo Changing date and time for director-2-2-A
exec ssh [email protected] "ntpd -q -g"
echo Finished synching director-2-2-A
echo
sleep 2
echo Changing date and time for director-2-2-B
exec ssh [email protected] "ntpd -q -g"
echo Finished synching director-2-2-B
sleep 2
echo
echo
echo Finished Synching SVT Cluster 2 directors with SMS.
The script only seems to complete after the first exec command.
Thu Aug 25 12:40:44 EDT 2011
Synching GTS Cluster 1 directors with SMS.
Changing date and time for director-1-1-A
Any help would be greatly appreciated =)
:g/exec/s/exec//(remove all the execs and it should work). Good luck.man shis likely a better way to find out what theexecbuilt-in does.man execgoes to theBASH_BUILTINSmanpage, whereexecis described - that way even someone who doesn't know exec is a builtin function of bash will get to the correct info.man execbrings up a man page with 4 columns, "Command", "External", "csh(1)", "sh(1)", giving Yes/No for each of the builtins (see freebsd.org/cgi/…) This shows the necessity of weasel words like "is likely" :-)