[OS X 10.4] Crontab restart doesn't work

Discussion in 'macOS' started by carlsson, Nov 29, 2014.

  1. carlsson macrumors regular

    carlsson

    Joined:
    Jul 18, 2001
    #1
    I want my old server to restart itself every night. So I edited the Crontab, added this:

    40 3 * * * shutdown -r now

    Still, it won't restart.

    What am I doing wrong? Is there a simpler way to make the Mac restart every night?
     
  2. carlsson thread starter macrumors regular

    carlsson

    Joined:
    Jul 18, 2001
    #2
    Hmmm, I changed the command to
    /sbin/shutdown -r now

    ...and now it works. It was not shut down gracefully though. :-|
     
  3. ScoobyMcDoo macrumors 65816

    Joined:
    Nov 26, 2007
    Location:
    Austin, TX
    #3
    Instead of the shutdown command, try this:

    Code:
    osascript -e 'tell app "System Events" to restart'
    It works from the command line, but haven't tried it from a cron job.
     
  4. carlsson thread starter macrumors regular

    carlsson

    Joined:
    Jul 18, 2001
    #4
    Thanks Scooby.

    However, the shutdown -r function works now with crontab and it all seems okey. I just want to confirm that the reboot is a graceful one. Do you know?
     
  5. ScoobyMcDoo macrumors 65816

    Joined:
    Nov 26, 2007
    Location:
    Austin, TX
    #5
    It is clean as far as the OS is considered. However I think the method I told you about will more safely shutdown a logged in session. For example, the shutdown -r will reboot even if you have a document opened an not saved.
     

Share This Page