How programmer gets his wife happy (part 2: iMessage)

Following my post about How programmer gets his wife happy, here is a simpler version for who is using Mac with Message app.

Forget all Twilio setup, you just need to create the cronjob. Replace the content and your wife’s number.

1. Create a file, put the command above.

/usr/bin/osascript -e 'tell application "Messages"
        send "Anh ban nhau, ve muon. Hon em." to buddy "+84988999888" of (service 1 whose service type is iMessage)
        end tell'
echo "Let go buddy"

2. Get it executable, and run at 18:30 every day.

MacBook-Pro:twilio hien$ chmod 775
MacBook-Pro:twilio hien$ vi /etc/crontab<

Add this line, correct your file path, 18, 30 is the hour and minute triggers this bash script.

30 18 * * * ~/Desktop/

3. Save this file and add to cronjob. That’s all.

MacBook-Pro:twilio hien$ crontab /etc/crontab

Life is easy if you are a programmer.