I wonder if there is a way to send an email to myself with Command Line or AppleScript service automatically when my Mac reboots? Thanks for your suggestions.

2 Answers 2


The easiest way I know of to do this is add a line to your crontab with the following format:

@reboot /path/to/your/script

The script could have the mail command invoking the date command.

  • Thanks for your help, Brian. But I have a little confusion. I know there is a script could send an email automatically from: apple.stackexchange.com/questions/125822/…. I mean if my Mac restarts unexpected, how can the Mac automatically send an email to me after restarts? Or if there is a way to send an email to me automatically after the Mac got an message that he was going to restart and he'll give out 10 seconds to send an email? Mar 12, 2016 at 11:27
  • Your Mac may restart for a lot of reasons, not all of them may give you a 10 seconds grace period. The crontab entry in the answer ensures that the script is run whenever your Mac is rebooted. The script itself needs to take care of actually composing and sending the mail.
    – nohillside
    Mar 12, 2016 at 13:37
  • Thanks, patrix. I understand what you try to tell me. After a search, I know how to add a line to my crontab, but it seems it doesn't work. My crontab is: @reboot /Users/Vincent-St/Desktop/Test.scpt, and the Test.scpt does work within Script.Edit. Does the script need to be a shell script instead of an Apple Script? I saw there were someone who said "Cron is not the right way to do this on OS X these days. Use LaunchAgent or LaunchDeamon instead (launchd)." Mar 13, 2016 at 2:59
  • @VincentSun You can't launch AppleScripts directly via cron (or launchd). osascript might help here, but if you need more details, please ask a new question.
    – nohillside
    Apr 9, 2016 at 7:04

You could use an AppleScript like this, saved as an application:

tell application "Mail"
    set my_message to make new outgoing message
    set subject of my_message to "I restarted."
    set content of my_message to "Not sure why it happened..."
    set sender of my_message to "[email protected]"
    tell my_message
        make new to recipient at end of to recipients with properties {name:"[email protected]"}
    end tell
    send my_message
end tell

Obviously you would change the sender and "to recipient" to your own email address.

You could then take the script, saved as an application, and add it to your login items. (This assumes that your Mac is set to login automatically.) See the picture. Last item shown in my login items is the script application.

Login Items in System Preferences, showing MyScript application will load at login

The key to this is saving the script as an application. That way, rather than opening the script, you're executing it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .