DIY an Timer Through Terminal-notifier

Today I will show you how to DIY an intersting notifier automatically running per hour under the Mac OS X 10.8 and higher, all we need are a terminal-notifier and the system built-in command line program named crontab.

1. Install the terminal-notifier

terminal-notifier is a program written in the awesome Ruby program language, we can visit the releases page and download the newest version of terminal-notifier. Steps to install it:

1. Please click the green button such as "terminal-notifier-1.5.0.zip" and select a path wherever you love to save the zip file;

2. After downloading completed, open the folder you selected in the above step, look for the zip file, and then double-click to extract the program;

3. Copy the extracted program terminal-notifier;

4. Click the "Applications" tab in the sidebar of your finder, and then paste the copied file.

5. Lastly, open a terminal and then run the following command to test if the notifier has been installed successfully.

/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title "Test Installation" -message 'your notifier has been installed successfully!'

You will see a notification message appears. If not, re-check your installation and make sure you have finished the above steps strictly.

2. Create the timer to notice you to have a break

In order to run the notifier periodically, we use crontab, which maintains crontab files for individual users.

Now, please open your terminal again, and then type the following command, run it:

crontab -e

Append the following line to the openning file:

0 * * * * /Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title "Guy, take a break please!" -message 'You have worked for a hour again, I suggest that you should take a break.'

Save the file and exit, your cron tasks will be updated automatically.

After every thing is finished, you will reveive the attentive message per hour. Cheers!

This post only acts like a demo, you can do more powerful works as you imagine.

Related Resources:

1. terminal-notifier

2. crontab

3. crontab man page

4. Linux Crontab: 15 Awesome Cron Job Examples

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值