Does anyone know how to write a bash script that will pull the time off of another server? I need a script that will poll the other server's time and start an event at a very specific period of time based on the time on the external server.
Why not just sync the time using NTP then use Cron to fire off the script at the appropriate time?
I second the use of NTP as it is the best way to get an accurate time synchronisation. You may need to install an NTP server on the external server if it doesn't already have one.
Cron will allow you to schedule a task down to the minute level. If you need it to be scheduled to a specific second or even more accurately, then you may need to write a program to poll the time and sleep as appropriate.
Well this will help you if you don't have strong time constraint.
You could write a script that will execute a script containing your command "date" In other words...
first script: remote_ssh.sh
#!/bin/bash
#connect to $machine and execute the script script2execute.sh
ssh $machine bash script2execute.sh
second script:` script2execute.sh
#!/bin/bash
# store your time on a file( or even a variable as you wish)
date > TIME.txt