- Open up Vi or your favorite editor on your virtual machine
- Type in the following details
- #!/bin/bash
service ntpd stop
sleep 5
ntpdate pool.ntp.org
sleep 5
service ntpd start - Save you file
- Change the permissions to all the file to be executable
- Run the following command
- #chmod 755 filename
- Test the command
- Run the following command
- #date
- You should see an incorrect time
- Run the script, note the "./" before the script name
- #./yourtimescriptname
- Run the following command
- #date
- You should see the correct time
- Now your virtual machine is updated
- You can add this script to a cron job or login script to automate the process
So far I just run this manually since I rarely reboot the virtual machine or login or out. You can make a symbolic link or an alias to make things easier to manage.
No comments:
Post a Comment