LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-12-2005, 09:57 AM   #1
rubella
Member
 
Registered: Sep 2005
Location: Europe
Distribution: debian sarge
Posts: 65

Rep: Reputation: 15
time cronjob


i'm trying to create a cronjob script to set correct time and date to my machine... the machine is running in vmware and time is always wrong... on the clock, there's a backupscript based on, that's why it's so important to have the correct time/date. I've tried several scripts, write my own, but they were terrible. someone knows a good one that will fix the job? google was not helpfull :s thx!
 
Old 10-12-2005, 10:24 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,902

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
You can use ntp to synchronize your box with a time server
Quote:
The Network Time Protocol (NTP) is used to synchronize the time of a
computer client or server to another server or reference time source,
such as a radio or satellite receiver or modem. It provides client
accuracies typically within a millisecond on LANs and up to a few tens
of milliseconds on WANs relative to a primary server synchronized to
Coordinated Universal Time (UTC) via a Global Positioning Service
(GPS) receiver, for example.
 
Old 10-12-2005, 11:09 AM   #3
rubella
Member
 
Registered: Sep 2005
Location: Europe
Distribution: debian sarge
Posts: 65

Original Poster
Rep: Reputation: 15
hey

it was easy as hell!
here we go:

apt-get update
apt-get install ntp

ntpdate <name of timeserver>
like 'ntpdate ntp.telenet.be'

that's it... :-) when you get ugly errors like: "the NTP socket is in use, exiting"

try to find the program using port 123 (ntp) with:
lsof -i udp:123
or
netstat -anf inet | grep 123

and kill them with:
kill <nr_of_pid>

try again: 'ntpdate ntp.telenet.be'

and, hopefully succesful!

add it to a cronjob like:
edit cron: crontab -e
add line to cron: 00 12 * * * ntpdate ntp.telenet.be

this cronjob will set correct time every day, 12 'o clock!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob help meeh Linux - General 1 03-26-2004 12:41 PM
Cronjob engnet Linux - Networking 6 03-03-2004 10:21 AM
cronjob ugob Linux - Software 0 03-03-2004 10:20 AM
Su in a cronjob michedlp Programming 3 11-06-2003 09:30 AM
cronjob FastEddy Linux - General 1 04-12-2003 10:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration