I'm new to conjobs and applescript but I have the script done correctly i believe. (any critique is welcome) I don't want to bloat my calendar with events to do this because I use my calendar for appointments and I don't need the bloat.

Here's my goal: run an apple script at 9am/5pm to enable/disable a mail account (after this works I'm going to add loging in/out of an Messenger account, first things first)

here's my script:

tell application "Mail" set offTime to 17 set onTime to 9

      set dayOfWeek to weekday of (current date)
      set theHour to get the (hours of (current date)) as string

      if theHour ≥ onTime then
                say "email on"
                set enabled of account "MAILBOX" to true

      else if theHour ≥ offTime or (dayOfWeek = Saturday or dayOfWeek = Sunday) then
                say "email Off"
                set enabled of account "MAILBOX" to false

      end if

end tell

accessing cron jobs via this

sudo pico /etc/crontab

and within cron jobs i've used

0 9 * * * username osacript

0 17 * * * username osacript

variations I've attempted (based on search engine results)

0 9 * * * username osacript

0 9 * * * /Documents/disablemail.scpt

0 9 * * * ~/Documents/disablemail.scpt

0 9 * * * osacript /Documents/disablemail.scpt

0 9 * * * osacript ~/Documents/disablemail.scpt

I think that's all of them.

Any feedback/assitance appreciated, thanks!

  • In cron ~ is not understood use thefull pathname
    – mmmmmm
    Commented May 8, 2013 at 16:08
  • @Mark It works for me in both the user's crontab and /etc/crontab.
    – Lri
    Commented May 8, 2013 at 18:25

2 Answers 2


Cron was replaced by launchd a while back. If you're just getting started with this project, you might want to do it in launchd.

  • But won't fix the issue
    – mmmmmm
    Commented May 8, 2013 at 16:43

The entries have to be on a single line. If you use /etc/crontab, the sixth field has to be the username:

0 9,17 * * * yourusername osascript ~/Documents/disablemail.scpt

You can edit the user's crontab with crontab -e (or EDITOR=pico crontab -e). The entries can't include username fields:

0 9,17 * * * osascript ~/Documents/disablemail.scpt

You must log in to answer this question.

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