Hot answers tagged

41

Use date -s: date -s '2014-12-25 12:34:56' Run that as root or under sudo. Changing only one of the year/month/day is more of a challenge and will involve repeating bits of the current date. There are also GUI date tools built in to the major desktop environments, usually accessed through the clock. To change only part of the time, you can use command ...


20

System time You can use date to set the system date. The GNU implementation of date (as found on most non-embedded Linux-based systems) accepts many different formats to set the time, here a few examples: set only the year: date -s 'next year' date -s 'last year' set only the month: date -s 'last month' date -s 'next month' set only the day: date -s ...


19

It probably depends on your cron implemenation, but the popular Vixie cron states in the manual: cron then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. and Special considerations exist when the clock is changed by less than 3 hours, for example at the ...


15

On Windows, the system RTC clock is traditionally kept in local time. In Unix and Linux, it's traditionally kept in UTC, and /etc/localtime is used to indicate the current timezone so that the displayed time is correct. These two worldviews collide in dual-boot configurations, because there's only one RTC. Usually you tell Linux to assume that the RTC is ...


9

date +%s%N will give the nano seconds since epoch To get the micro seconds just do an eval expr `date +%s%N` / 1000


8

I have found the solution thanks to the tip given by Nils and a nice article. Tuning the ondemand CPU DVFS governor The ondemand governor has a set of parameters to control when it is kicking the dynamic frequency scaling (or DVFS for dynamic voltage and frequency scaling). Those parameters are located under the sysfs tree: /sys/devices/system/cpu/cpufreq/...


8

You can use : sudo dpkg-reconfigure tzdata for configuring your timezone . For updating time and date from internet use the following : Install If ntpd is not installed use any one of the following command to install ntpd: # yum install ntp Configuration You should at least set following parameter in /etc/ntp.conf config file: server For example,...


8

Are there tools which measure time of day clock drift? The only tools I'm aware of are the NTP tools which should suffice. You don't have to actually configure ntpd to sync against a given clock source you can just use the -d option to ntpdate to fetch the calculated offset. Example: [davisja5@xxxadmvlm08 ~]$ ntpdate -d clock.redhat.com 2>/dev/null | ...


8

There's no much point asking for this kind of precision in a shell script, given that running any command (even the date command) will take at least a few hundreds of those microseconds. In particular, you can't really use the date command to time the execution of a command with this kind of precision. For that, best would be to use the time command or ...


6

The guest has no direct access to the host clock. Instead, it uses kvm-clock which points to a memory region updated by the host, from the host's clock. As such, the guest is using the host clock. The issue is that this memory region isn't updated constantly, it's only updated when there's a VM 'event', and as such, guests can drift and then lurch back to ...


6

Change the following line in /etc/hosts 127.0.0.1 localhost to 127.0.0.1 localhost orion Your MTA was unable to resolve the domain name of your machine.


5

As mentioned, the host writes the time to a page of memory that the guest can read. This generally means that the vm's hardware clock matches the host's, barring any bugs where the host doesn't write that page on critical events like scaling cpu speed. The issue is usually that the OS doesn't recognize that the hardware clock is changing/adjusting. A regular ...


5

Use ntpdate, ntpd, or Chrony to connect to a NTP server.


5

The system clock and the hardware clock are not the same. The command hwclock -r should show you the time the hardware clock is set to. If it is incorrect, use the command hwclock -w to update it when the time is correct. If you dual boot with windows, you will want to use local time. Otherwise, you may want to set the harward clock to UTC with the ...


5

Jodka Lemon's answer is correct: cron executes its job, and sends a result mail to "root@orion" (via "mail" or similar) the MTA cannot resolve host orion, since the hostname is not listed in /etc/hosts and not resolvable via dns. so the mailer writes the dead letter information You will find the destination address of crons mail output in the crontab ...


4

I've seen syslog entries like that on a Slackware machine a few years ago. I believe I bought the machine in question in 2002, and pretty much ran it 24/7 for years: it was my SSH, SMTP and HTTP server. The NTP failures came on slowly, and gradually increased in frequency. I fixed it the first time by changing the "CMOS RAM" battery, which was one of ...


4

It is not the guest that triggers the upscale - the host must do this. So you have to lower the according trigger-level on the host.


4

To expand slightly upon @frostschutz comment, the TZ environment variable is present in large part to allow exactly what you desire: having programs show you time information in your preferred zone. Indeed, Unix system clocks all run on UTC (GMT-like) and things like file timestamps and what your clock program gets back from the system is in UTC. Programs ...


4

Some distributions are shipping rdate for that purpose. Basic usage: # just query bash-4.2$ rdate pool.ntp.org rdate: [pool.ntp.org] Wed Jun 12 11:05:40 2013 # set system time bash-4.2$ rdate -s pool.ntp.org


4

It sound slike one of your systems is configured to treat the hardware clock as localtime, while the other one treats it as UTC. Ubuntu docs leave me to believe Ubuntu is UTC by default, so probably your Arch isn't. You can check and set this by checking if timedatectl status | grep local returns anything, and set Arch to use UTC by saying timedatectl ...


4

The command to set the system time is date. You need to be root to set the system time. date sets the time to the given time, not to a relative amount from the current time, because that latter behavior would be pretty pointless. You can build a command that modifies the current time by a relative amount by making a calculation on the output of date and ...


4

By system clock I mean the clock that tells the time down right of the panel "System clock" generally refers to the clock maintained by the kernel; applications such as date and GUI clocks such as the one you refer to make calls to it like this. Why, out of all the processes that the system runs, does the clock need a shared memory segment? There's ...


4

As you said date +%s returns the number of seconds since the epoch. So, date +%s%N returns the seconds and the current nanoseconds. Dividing date +%s%N the value by 1000 will give in microseconds.i.e echo $(($(date +%s%N)/1000))


4

You could write a function that does both: set_both_clocks() { date "$@" hwclock -w } Give it the exact same arguments you'd give to date when setting the system clock.


4

By the time the data reaches your PC via the USB/RS232 interface, the resolution and accuracy wont be any good. At the end of the day, without dedicated equipment, it is better to stay with NTP. From this GPS synchronization tutorial There are many cheap GPS receivers available in the market. Most of them use either an RS232, or USB connection to send ...


4

There are two things you should do. Make sure ntpd is started as early as possible in the boot sequence, and put an ntp-wait somewhere in the boot sequence before any of your applications start. Depending on your version of Linux, how you achieve that will vary. You should, however, make your application startup dependant on the ntp-wait finishing. ntp-...


4

date makes no effort to synchronize with anything at all, and merely makes some system call (that on linux a strace date ... may or may not show) to lookup the time since the epoch as known by the system. The system itself may synchronize with the BIOS clock, or if a virtual machine may obtain the current time from the parent it runs under, or may use NTP (...


3

If you take a look at the Wikipedia page regarding the TZ database: excerpt File formats The tz database is published as a set of text files which list the rules and zone transitions in a human-readable format. For use, these text files are compiled into a set of platform-independent binary files—one per time zone. The reference source code ...


3

I see a few ways you can approach this Scan the filesystem for the file with the newest modification or access time. Use that time to set the clock. It's slow, and the accuracy is probably going to be far off, but it'll work. If you have a directory/file you know is modified fairly frequently, you could just use that as the source. Go with the idea you ...


3

Besides what was already said about kvm-clock, you might want to try the standard best practices - get away from tickless kernels, downshift the kernel ticks to 10 or so, enable ntpclient, make sure the host is not overloaded - time drift often happens during heavy CPU overcommit. If the VM has lots of virtual CPUs assigned, take that number down a few ...



Only top voted, non community-wiki answers of a minimum length are eligible