Shell commands to set the clock
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    I want know if there are shell commands to set the clock system, I have on PowerBook without the clock battery and I want make a little tool to set clock when I start the mac, and I need if there is a command of style setclock, etc.
  • »12.11.19 - 10:46
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 2971 from 2003/3/5
    From: Canada
    I'd recommend adding 'setclockntp save' to your user-network-startup file.
  • »12.11.19 - 10:50
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    Thank you for the suggestion, I have it with capital letters the SAVE option, but every time that I start my machine the clock has 1978, and when I click in the clock to set a current date it changes to 1985, I want to have the date of the last time that I started my mac.
    And my idea is make a program to make it.
  • »12.11.19 - 11:07
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    The problem continues the user-network-startup file not make nothing.
  • »14.11.19 - 09:32
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 2971 from 2003/3/5
    From: Canada
    Well, does 'setclockntp' help when run from shell? Did you set a timezone in Time settings?

    [ Edited by jacadcaps 14.11.2019 - 13:21 ]
  • »14.11.19 - 13:21
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    Quote:

    jPV escribió:
    @Templario

    Is your machine connected to Internet? :) SetClockNTP tries to sync the clock from the Internet...

    SetClock can be used to manually set the clock.

    https://library.morph.zone/Shell_Commands/SetClock
    https://library.morph.zone/Shell_Commands/SetClockNTP


    Thank you for your help, I was finding a shell command to set the time date and hour because these commands are to use the clock with battery, and my mac hasn't it.
    My idea is make a little tool or ARexx command to save to a txt file with the date and hour and read it to set when I not use Internet.
  • »18.11.19 - 12:13
    Profile
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2026 from 2003/2/24
    From: po-RNO
    Quote:

    Templario wrote:
    Thank you for your help, I was finding a shell command to set the time date and hour because these commands are to use the clock with battery, and my mac hasn't it.
    My idea is make a little tool or ARexx command to save to a txt file with the date and hour and read it to set when I not use Internet.

    Oops, sorry. Those my previous suggestions aren't good for that indeed.

    But the Date command would be better, and some shell scripts would probably be enough, no need to go to heavier scripting/programming

    For example, to save the date to a file:
    Date > ENVARC:mytimehack

    and then to set the date from the file:
    Date >NIL: ? < ENVARC:mytimehack

    ...or something like that.

    You could, for example, to make a shell script that you use to shutdown/reboot the machine always:
    Code:
    Date > ENVARC:mytimehack
    RequestChoice >ENV:rcnum "SHUTDOWN" "Press enter to shutdown or wait 10s to cancel." "Shutdown" "Reboot" "Cancel" TYPE=1 TIMEOUT=10
    Wait 2
    If 1 EQ $rcnum
    Shutdown
    Quit
    EndIf
    If 2 EQ $rcnum
    Reboot
    Quit
    EndIf


    And then have that "Date >NIL: ? < ENVARC:mytimehack" in s:user-startup...

    But of course the clock will be wrong when your machine is off for a longer time and lose time in reboots, how did you think to handle that?
  • »18.11.19 - 14:39
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    Thank you for your help, only the Date >NIL:? <ENVARC:MyHour not works, isn't open redirection file.
    The reboot well, it will be a single command with a shell icon to adjust it, this is the idea.
  • »18.11.19 - 16:42
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 779 from 2007/10/23
    From: Gelsenkirchen,...
    How about this?
    Code:
    Date $MyHour
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1 17", MorphOS 3.18
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.18
  • »19.11.19 - 00:32
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    Thank you for your help, already I make me a little Hollywood tool for this problem.
  • »20.11.19 - 09:31
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    Hi again other question are there any shell command to call to MorphOS Preferences to change the date and hour like under AmigaOS3.x the Time preferences tool?

    [ Editado por Templario 22.11.2019 - 12:29 ]
  • »22.11.19 - 10:40
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Templario
    Posts: 532 from 2012/4/28
    Quote:

    jPV escribió:
    SYS:MorphOS/Prefs/Preferences Time



    Thank very much for your big help, I could tested that with this instruction you can call to other Preferences options, and I added to my little program to clock battery problem. Again thank you very much.
  • »23.11.19 - 09:05
    Profile