waltd...@waltdnes.org <waltd...@waltdnes.org> [16-01-11 04:04]: > On Sun, Jan 10, 2016 at 02:55:57PM +0100, meino.cra...@gmx.de wrote > > Hi, > > > > currently I am experimenting with a new embedded system > > (OrangePI PC). I want to suspend the system to RAM. > > After a period of time the system should wakeup. > > > > The RTC on the board seems to support alarms. > > > > Is there a tool to set the alarm time of an RTC > > from the commandline like hwclock set the RTC > > time itsself? > > > > I couldn't find one (or successfully overlooked it...) > > > > Thank you very much in advance for any help! > > Best regards, > > Meino > > I'm not aware of any utilities. Is it linux, and how good are you at > shell scripts? Two virtual files you'll need to know about are... > > /sys/class/rtc/rtc0/since_epoch > /sys/class/rtc/rtc0/wakealarm > > Note that writing to /sys requires root privileges. Both files are in > seconds since 1970-01-01 00:00:00 UTC. This is the same output that > "date +%s" produces. To test it, run the command... > > date +%s ; cat /sys/class/rtc/rtc0/since_epoch > > Let's say that you want it wake up in 3 minutes (i.e. 180 seconds from > now). You'll have to use either "eval" or backticks. The command > would be... > > #!/bin/bash > echo $(( 180 + `cat /sys/class/rtc/rtc0/since_epoch` )) > > /sys/class/rtc/rtc0/wakealarm > > ...and powerdown. It should wake up 3 minutes after you issued the > command. > > How about specifying a future time, you ask? First, we need to know > the input format. The "--date" command uses the format > "MM/DD/YYYY HH:mm:ss" (Month/Day/Year Hour:Minute:Second) > the brackets indicate optional items. To get the seconds since epoch at... > > year 2016 > month 01 > day 20 > hour 23 > minute 00 > second 00 > > the command is... > > date +%s --date="01/20/2016 23:00:00" > > ...which outputs 1453348800 > > To set a wakeup alarm for that time... > > date +%s --date="01/20/2016 23:00:00" > /sys/class/rtc/rtc0/wakealarm > > You'll probably want to write a script to accept input from a user or > another program. Beware of UTC offsets and Daylight Saving Time. > > -- > Walter Dnes <waltd...@waltdnes.org> > I don't run "desktop environments"; I run useful applications >
Hi Walter, THANKS :) for explanation...I am quite familiar with shell scripting under Unices... :) Your mail will help me a lot! Best regards, Meino