4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

定刻にMacからチャイムを鳴らす

Last updated at Posted at 2020-05-04

やりたいこと

  • タイトル通り
  • 想定するユースケース:定期的に発生、かつ開始時間やインターバルが決まっているイベント
  • オンライン授業とか、週次会議とか、休憩とか

方針

  • crontab:コマンドを定時に実行させるコマンド
  • 手元の環境はmacOS Catalina v10.15.4

方法

  • crontabコマンドの使い方チュートリアル:crontabの書き方がおすすめ

  • afplay(ターミナルからオーディオファイルを再生するコマンド)を併用

  • 予め任意のmp3ファイルを好きなパス(ここでは~/Music/chime.mp3)に置いておく

  • crontabの編集

$ crontab -e
  • デフォルトのエディタでcrontab.XXXXXXXXXXみたいなファイルが開かれる
  • 好みの設定を記述して、ファイルを保存・エディタquit
25 8 * * mon-fri afplay ~/Music/chime.mp3
20 10 * * mon-fri afplay ~/Music/chime.mp3
55 12 * * mon-fri afplay ~/Music/chime.mp3
50 14 * * mon-fri afplay ~/Music/chime.mp3
# Comment for the newline of crontab termination character. See man 5 crontab

参考

おわり

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?