1

Again I am in a serious problem .. please help me out.

I have to change a date and time of a server which is linux based . But that server is a remote server . Means I have to make an application which will change the time of the server , but that application will run on separate server. I am developing my code in java so I have to implement it with a java program please help me out. and tell me how to solve this problem. If possible give me the code spec. If it is possible by doing ssh then please tell me how to create ssh using a java program. I am giving the scenario the java program should run on machine A and i have to change the server date time of machine B.

2
  • 1
    Can you not ssh into the remote server and sudo date --set="DD MON YYYY HH:MM:SS"? Commented Mar 22, 2011 at 6:59
  • 1
    Don't mix server management tasks with application design. You also need to give a lot more detail then you have currently, as their are a lot of bad answers. Commented Mar 22, 2011 at 7:03

2 Answers 2

1

Your Java program should not have to do that. However if it must be done, you can execute commands on a remote server via SSH.

There are multiple libraries for Java that would let you write programs that run commands via SSH. One such library is:

http://www.cleondris.ch/opensource/ssh2/

Java Example with this library:

http://www.informit.com/guides/content.aspx?g=java&seqNum=489

Sign up to request clarification or add additional context in comments.

Comments

1

An answer to this question: "How do I set the datetime of a remote machine?" (your question, as I understood it).

Not necessarily a problem which must be solved with a three-tier java stack. If you have an ssh account for the machine, just log in and run date:

$ ssh [email protected]
$ date -s "7 April 2008 20:42:45"

You can run remote commands from your local shell by simply putting ssh in the front, e.g.:

$ ssh [email protected] date -s "7 April 2008 20:42:45"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.