How to set system time from Unix timestamp

datetimestamps

I know arbitrary timestamp and I want to set system time using it. I've tried following:

date +%s -s "1371729865"
date +%s -s '1371729865'
date +%s -s 1371729865

but without success.

The idea is, that I launch system on remote device without internal RT clock (RaspberryPi), and I need to set system time for logging purposes. I don't need exact time.

On RPi I have access to network, but not to internet and I will be sending the time as packet in my application.

Best Answer

You missed @ character before unix timestamps, try:

date +%s -s @1371729865
Related Question