Run script from another server

If i have one server processing some feeds and creating a database. Then i want to copy the relevant tables from the first server to the second server. I have a shell script to do the copy. I was going to make a cron to run the script at a certain time. But it would not be ideal. I really want to somehow make absolutely sure that the first server has finished processing the feeds before the second server runs the DB import script. So rather than using a cron i wondered if there was a simple way to start the process from other server.

I guess i could use a password protected web page to achieve this. But i wondered if there was a nice way in unix?

You could always rcp a dummy file on second server when first has finished its processing...
And use cron for checking the presence of dummy (dont forget to remove it after...) and launch the import on the second server...
If you know its just a question of waiting, you could schedule at fixed time and in your cron script testing the presence of dummy, if not found reschedule using at command

You can use SSH to execute a command on the remote server.

echo "<your command here>" | ssh -C -l <user> <host>
if [ ${?} -ne 0 ]
then
      echo "ERROR: Command failed."
else
      echo "INFO: Command successfull."
fi

Regards.

Thanks for your reply's. With the ssh method how do i supply password for the ssh function.

Would it be

echo "sh /scripts/myscript.sh" | ssh -C -l username:password 24.212.39.32
if [ ${?} -ne 0 ]
then
      echo "ERROR: Command failed."
else
      echo "INFO: Command successfull."
fi

I know when i run rsync scripts i dont need the passwords. Maybe this is the same?

.... because you have already set up and installed your public and private key pairs which were created without a password.

You can set this up the same way for SSH, BTW (that is if the keypairs you generated for rsync will not work for ssh, which I am not sure of without doing some research).

I am not sure if there is another way, but if when you use rsync, it is over SSH, probably, as commented by NEO, you already have keypairs setup, so you will not need to provide a password.

If you want to know how keypairs setup work, check this link: OpenSSH Public Key Authentication

I hope it helps.

I tried this and it asked for a password i guess the key pairs are not set up for ssh. Does this mean my rsync uses rsh. How can i find this out? Here is what i put

echo "sh /home/scripts/test.sh" | ssh -C -l root 24.212.39.32
Pseudo-terminal will not be allocated because stdin is not a terminal.
Password:

I entered the root password and the script ran.
Should i set up the keypairs with ssh or should i supply the password in the ssh command if i can?

SSH means Secure Shell, so in shell scripts there is no way to specify the password in command line, the option here is to setup keypairs.

To avoid this: "Pseudo-terminal will not be allocated because stdin is not a terminal", add the "-T" option to ssh:

echo "sh /home/scripts/test.sh" | ssh -T -C -l root 24.212.39.32

Check it, generally is not a good practice to exchange keys with root user!

Regards.

Thanks for the info