$crontab -e
MAILTO=xxxx@gmail.com 40 0 21 5 * ~/cmd.sh
参考
cronの通知先メールアドレスを変更したい
$crontab -e
MAILTO=xxxx@gmail.com 40 0 21 5 * ~/cmd.sh
$ sudo apt-get install ssmtp2、ssmtpの設定
$ sudo vi /etc/ssmtp/ssmtp.conf
# # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. #root=postmaster # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com mailhub=smtp.gmail.com:587 # Where will the mail seem to come from? #rewriteDomain= # The full hostname #hostname=raspberrypi # Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address #FromLineOverride=YES AuthUser=Gmailのアカウント名 AuthPass=Gmailのパスワード AuthMethod=LOGIN UseSTARTTLS=YES UseTLS=Yes3、送信テスト
$ vi mailtest.txt
From:gmailのメールアドレス To:あて先メールアドレス Subject:test Mail Test
$ sendmail -t < mailtest.txt
$ sudo update-alternatives --config editor alternative editor (/usr/bin/editor を提供) には 3 個の選択肢があります。 選択肢 パス 優先度 状態 ------------------------------------------------------------ * 0 /bin/nano 40 自動モード 1 /bin/ed -100 手動モード 2 /bin/nano 40 手動モード 3 /usr/bin/vim.tiny 10 手動モード 現在の選択 [*] を保持するには Enter、さもなければ選択肢の番号のキーを押してください: 3 update-alternatives: /usr/bin/editor (editor) を提供するために 手動モード で /usr/bin/vim.tiny を使います