The RaspberryPi starts up with a default time.
The July Raspbian kernel starts up with July 15 about 19:41:xx, and
the August version starts up Aug 16 00:59:xx.
How could one change the date and time on the SD card so that it would boot up with a different time?
It might make it easier for those who have USB keyboard and network problems to tell what part of log files came from which sessions.
- Licaon_Kter
- Posts: 240
- Joined: Wed Sep 05, 2012 10:12 am
- Location: Between the keyboard and the chair.
Re: From where comes the default time?
it's saved
so an image will have the "image creation time"
when you run the Pi time passes
when shutdown time is saved
on start time continues where it was left out
if you do set up the correct time it will use it, for now, but if you stop it for 10 days then it will start with the past time...
/LE: it's a broken time-machine actually

so an image will have the "image creation time"
when you run the Pi time passes
when shutdown time is saved
on start time continues where it was left out
if you do set up the correct time it will use it, for now, but if you stop it for 10 days then it will start with the past time...
/LE: it's a broken time-machine actually


Last edited by Licaon_Kter on Wed Sep 12, 2012 3:07 pm, edited 1 time in total.
BFQ+BFS or RT on a RPi? 4'real: https://github.com/licaon-kter/ (source and compiled!)
- Licaon_Kter
- Posts: 240
- Joined: Wed Sep 05, 2012 10:12 am
- Location: Between the keyboard and the chair.
Re: From where comes the default time?
double post
Last edited by Licaon_Kter on Wed Sep 12, 2012 3:07 pm, edited 2 times in total.
BFQ+BFS or RT on a RPi? 4'real: https://github.com/licaon-kter/ (source and compiled!)
Re: From where comes the default time?
sudo date mmddhhmm
should set it
but if you plug it in to a network it'll get the date from that
should set it
but if you plug it in to a network it'll get the date from that
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
WARNING - some parts of this post may be erroneous YMMV
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe
- bonelifer
- Posts: 128
- Joined: Thu Jan 12, 2012 4:01 am
- Location: http://www.phpbb.com/community/memberli ... e&u=147848
Re: From where comes the default time?
For the OP, specifically it's using the "Network Time Protocol daemon(service)". Basically if you have your Pi connected to the internet it will retrieve the time and date from a NTP server. If you want a more in depth description: http://www.linuxhomenetworking.com/wiki ... NTP_ServerRaTTuS wrote:sudo date mmddhhmm
should set it
but if you plug it in to a network it'll get the date from that
You could add an RTC board and do an initial NTP update and write that to the RTC board, here's a link to one description of doing that:
http://www.element14.com/community/grou ... pi-via-i2c
A little simpler way: http://www.raspberrypi.org/phpBB3/viewt ... 29&t=13710
Re: From where comes the default time?
Is there some kind of memory that retains the time for about 10 days after power is removed? I wonder if that could be why my RaspberryPi worked well the second time after it was off for a week or so.Licaon_Kter wrote: if you do set up the correct time it will use it, for now, but if you stop it for 10 days then it will start with the past time...
I tried writingRaTTuS wrote:sudo date mmddhhmm
should set it
but if you plug it in to a network it'll get the date from that
sudo date 09142300
with my PC into a new /boot/cmdline.txt file on the SD card so that it would run when I booted, but it didn't affect the date-timestamps recorded in kern.log for the new group of messages. I changed it to
date 09140700
and tried again, but that didn't work either.
Setting the date and time would be nice because they are put on every line of the log file and that would make it easier to distinguish sessions. In my case the keyboard and network usually don't work, so I cannot use the shutdown command and I usually end the session trying to log on and then turning off the RaspberryPi. (The keyboard and network did work quite well for one several hour session, and my only other good long session used a different keyboard.)
I suppose line numbering alone would suffice... it just seemed that the date timestamp would be good.
I wonder if I put cmdline.txt in the wrong place, or is there a different file and location I should use? Or, maybe Raspbian (July version) does not run cmdline text before getting to the login prompt? (This is where my RaspberryPi stops because I cannot log in with the keyboard. Sample errors from kern.log are shown below. I would have used the latest version, the August version, but it stops in raspi-config.)
Code: Select all
Aug 21 05:17:29 raspberrypi kernel: [ 18.391421] ### BCM2835 ALSA driver init OK ###
Aug 21 05:17:29 raspberrypi kernel: [ 26.270387] smsc95xx 1-1.1:1.0: eth0: Failed to write register index 0x00000020
...
Aug 21 05:17:35 raspberrypi kernel: [ 38.459950] hub 1-1:1.0: hub_port_status failed (err = -19)
...
Aug 21 05:17:37 raspberrypi kernel: [ 40.919984] usb 1-1: new high speed USB device number 8 using dwc_otg
Aug 21 05:17:37 raspberrypi kernel: [ 41.339960] usb 1-1: device not accepting address 8, error -71
Aug 21 05:17:37 raspberrypi kernel: [ 41.340086] hub 1-0:1.0: unable to enumerate USB device on port 1
- Licaon_Kter
- Posts: 240
- Joined: Wed Sep 05, 2012 10:12 am
- Location: Between the keyboard and the chair.
Re: From where comes the default time?
> Is there some kind of memory that retains the time for about 10 days after power is removed?
it's written on the SD card, evidently
> with my PC into a new /boot/cmdline.txt file on the SD card so that it would run when I booted
that won't work
better try to fix your issues, post details about that, and stop worrying about the clock and the time
it's written on the SD card, evidently

> with my PC into a new /boot/cmdline.txt file on the SD card so that it would run when I booted
that won't work
better try to fix your issues, post details about that, and stop worrying about the clock and the time

BFQ+BFS or RT on a RPi? 4'real: https://github.com/licaon-kter/ (source and compiled!)
Solved: From where comes the default time?
It was embarrassingly easy
to adjust the default time, but it was a good newbie exercise to find out how.
An internet search guided me to the /sbin/hwclock program. I mounted the SD card to a PC running Linux and went to that directory. Using cat hwclock showed a parade of symbols representing the binary code, so that didn't help. Fortunately, I entered ls and happened to see elsewhere in the /sbin directory a listing for fake-hwclock. The cat command showed that file to be text, and it references the file /etc/fake-hwclock.data. With a cd ../etc and cat fake-hwclock.data, I could see the data used for the default time:
2012-08-21 05:17:10
So I did echo 2012-09-15 23:00:00 > fake-hwclock2.data to make a new data file and ls -l fake-hw*.* to see the files were the same size:
-rw-r--r-- 1 root root 20 Aug 21 05:17 fake-hwclock.data
-rw-r--r-- 1 root root 20 Sep 15 23:23 fake-hwclock2.data
I swapped in the new file:
mv fake-hwclock.data fake-hwclock-BAK.data
mv fake-hwclock2.data fake-hwclock.data
so ls -l fake-hw*.* gives:
-rw-r--r-- 1 root root 20 Aug 21 05:17 fake-hwclock-BAK.data
-rw-r--r-- 1 root root 20 Sep 15 23:23 fake-hwclock.data
I booted (still had the keyboard problem), but when I checked the updated /var/log/kern.log file (See how to get to that file using linux on another computer when keyboard and network don't work at http://www.raspberrypi.org/phpBB3/viewt ... 24&t=13563), I saw the first new line with the new default date:
...
Aug 21 05:17:37 raspberrypi kernel: [ 41.339960] usb 1-1: device not accepting address 8, error -71
Aug 21 05:17:37 raspberrypi kernel: [ 41.340086] hub 1-0:1.0: unable to enumerate USB device on port 1
Sep 15 23:00:20 raspberrypi kernel: imklog 5.8.11, log source = /proc/kmsg started.
Sep 15 23:00:20 raspberrypi kernel: [ 0.000000] Initializing cgroup subsys cpu
Sep 15 23:00:20 raspberrypi kernel: [ 0.000000] Linux version 3.1.9+ (dc4@dc4-arm-01) (gcc version 4.5.1 (Broadcom-2708) ) #168 PREEMPT Sat Jul 14 18:56:31 BST 2012
...
It's a mere crumb, but it a little bit of success and adds to the knowledge.


An internet search guided me to the /sbin/hwclock program. I mounted the SD card to a PC running Linux and went to that directory. Using cat hwclock showed a parade of symbols representing the binary code, so that didn't help. Fortunately, I entered ls and happened to see elsewhere in the /sbin directory a listing for fake-hwclock. The cat command showed that file to be text, and it references the file /etc/fake-hwclock.data. With a cd ../etc and cat fake-hwclock.data, I could see the data used for the default time:
2012-08-21 05:17:10
So I did echo 2012-09-15 23:00:00 > fake-hwclock2.data to make a new data file and ls -l fake-hw*.* to see the files were the same size:
-rw-r--r-- 1 root root 20 Aug 21 05:17 fake-hwclock.data
-rw-r--r-- 1 root root 20 Sep 15 23:23 fake-hwclock2.data
I swapped in the new file:
mv fake-hwclock.data fake-hwclock-BAK.data
mv fake-hwclock2.data fake-hwclock.data
so ls -l fake-hw*.* gives:
-rw-r--r-- 1 root root 20 Aug 21 05:17 fake-hwclock-BAK.data
-rw-r--r-- 1 root root 20 Sep 15 23:23 fake-hwclock.data
I booted (still had the keyboard problem), but when I checked the updated /var/log/kern.log file (See how to get to that file using linux on another computer when keyboard and network don't work at http://www.raspberrypi.org/phpBB3/viewt ... 24&t=13563), I saw the first new line with the new default date:
...
Aug 21 05:17:37 raspberrypi kernel: [ 41.339960] usb 1-1: device not accepting address 8, error -71
Aug 21 05:17:37 raspberrypi kernel: [ 41.340086] hub 1-0:1.0: unable to enumerate USB device on port 1
Sep 15 23:00:20 raspberrypi kernel: imklog 5.8.11, log source = /proc/kmsg started.
Sep 15 23:00:20 raspberrypi kernel: [ 0.000000] Initializing cgroup subsys cpu
Sep 15 23:00:20 raspberrypi kernel: [ 0.000000] Linux version 3.1.9+ (dc4@dc4-arm-01) (gcc version 4.5.1 (Broadcom-2708) ) #168 PREEMPT Sat Jul 14 18:56:31 BST 2012
...
It's a mere crumb, but it a little bit of success and adds to the knowledge.
Last edited by Jonn on Sun Sep 16, 2012 4:23 am, edited 1 time in total.
-
- Posts: 4277
- Joined: Sun Jan 15, 2012 1:11 pm
Re: From where comes the default time?
This is good to know.
Thanks for doing the research - and posting it here (in great detail). Good job.
Thanks for doing the research - and posting it here (in great detail). Good job.
And some folks need to stop being fanboys and see the forest behind the trees.
(One of the best lines I've seen on this board lately)
(One of the best lines I've seen on this board lately)