{"id":2116,"date":"2018-09-16T07:18:17","date_gmt":"2018-09-15T22:18:17","guid":{"rendered":"http:\/\/matoken.org\/blog\/?p=2116"},"modified":"2018-09-16T07:18:17","modified_gmt":"2018-09-15T22:18:17","slug":"i-want-to-specify-the-subject-of-e-mail-sent-from-crontab","status":"publish","type":"post","link":"https:\/\/matoken.org\/blog\/2018\/09\/16\/i-want-to-specify-the-subject-of-e-mail-sent-from-crontab\/","title":{"rendered":"crontab \u304b\u3089\u9001\u4fe1\u3055\u308c\u308b\u96fb\u5b50\u30e1\u30fc\u30eb\u306e\u4ef6\u540d\u3092\u6307\u5b9a\u3057\u305f\u3044"},"content":{"rendered":"<div id=\"preamble\">\n<div class=\"sectionbody\">\n<div id=\"__asciidoctor-preview-476__\" class=\"paragraph\">\n<p>crontab \u3067\u5b9f\u884c\u3055\u308c\u305f\u30b3\u30de\u30f3\u30c9\u306e\u51fa\u529b\u306f\u30e1\u30fc\u30eb\u3067\u9001\u3089\u308c\u307e\u3059\u304c\uff0c\u3053\u306e\u3068\u304d\u306e\u4ef6\u540d\u306f\u300cCron &lt;\u30e6\u30fc\u30b6\u540d@\u30db\u30b9\u30c8\u540d&gt; \u5b9f\u884c\u30b3\u30de\u30f3\u30c9\u300d\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<\/div>\n<div id=\"__asciidoctor-preview-484__\" class=\"listingblock\">\n<div class=\"title\">crontab \u4f8b<\/div>\n<div class=\"content\">\n<pre>15 7 * * *  echo \"cron subject\"<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-492__\" class=\"listingblock\">\n<div class=\"title\">\u30e1\u30fc\u30eb\u4f8b<\/div>\n<div class=\"content\">\n<pre>Subject: Cron &lt;matoken@T430s&gt; echo \"cron subject\"\r\n\r\ncron subject<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-500__\" class=\"listingblock\">\n<div class=\"title\">1\u3064\u306ehost\u304b\u3089\u3053\u3093\u306a\u30e1\u30fc\u30eb\u98db\u3093\u3067\u6765\u308b\u3068\u3069\u308c\u304c\u3069\u308c\u304b\u308f\u304b\u308a\u3065\u3089\u3044<\/div>\n<div class=\"content\">\n<pre>Cron &lt;matoken@T430s&gt; nice -n 19 ionice -c 3 rsync -avxze \"ssh -i\u2026\u2026\r\nCron &lt;root@T430s&gt; nice -n 19 ionice -c 3 rsync -avxze \"ssh -i\u2026\u2026\r\nCron &lt;root@T430s&gt; nice -n 19 ionice -c 3 rsync -avxze \"ssh -i\u2026\u2026<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-504__\" class=\"paragraph\">\n<p>\u5206\u304b\u308a\u3065\u3089\u3044\u306e\u3067\u81ea\u5206\u3067\u4ef6\u540d\u3092\u4ed8\u3051\u305f\u3044\u3068\u3053\u308d\u3067\u3059\uff0e<\/p>\n<\/div>\n<\/div>\n<div id=\"toc\" class=\"toc\">\n<div id=\"toctitle\">Table of Contents<\/div>\n<ul class=\"sectlevel1\">\n<li><a href=\"#__\">: \u3092\u5229\u7528\u3059\u308b<\/a><\/li>\n<li><a href=\"#_mail\">mail\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3059\u308b<\/a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_stderr\">STDERR \u304c\u5225\u30e1\u30fc\u30eb\u3067\u5c4a\u304f<\/a><\/li>\n<li><a href=\"#___2\">\u51fa\u529b\u304c\u306a\u304f\u3066\u3082\u30e1\u30fc\u30eb\u304c\u5c4a\u304f<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#___3\">\u4f59\u9332<\/a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_cron\">cron\u3067\u4e00\u5207\u30e1\u30fc\u30eb\u3092\u9001\u308a\u305f\u304f\u306a\u3044<\/a><\/li>\n<li><a href=\"#___4\">\u6307\u5b9a\u3057\u305f\u30b3\u30de\u30f3\u30c9\u3060\u3051\u30e1\u30fc\u30eb\u3092\u9001\u308a\u305f\u304f\u306a\u3044<\/a><\/li>\n<li><a href=\"#___5\">\u30e1\u30fc\u30eb\u304c\u5c4a\u304b\u306a\u3044<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"__\">: \u3092\u5229\u7528\u3059\u308b<\/h2>\n<div class=\"sectionbody\">\n<div id=\"__asciidoctor-preview-530__\" class=\"paragraph\">\n<p>: \u306f shell \u306e\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u3067\u4f55\u3082\u305b\u305a\u6b63\u5e38\u7d42\u4e86\u3057\u307e\u3059\uff0e<br \/>\n\u30b3\u30de\u30f3\u30c9\u306a\u306e\u3067 # \u3068\u9055\u3044\uff0c; \u306e\u5f8c\u306b\u30b3\u30de\u30f3\u30c9\u3092\u66f8\u304f\u3068\u305d\u306e\u5f8c\u306e\u30b3\u30de\u30f3\u30c9\u306f\u89e3\u91c8\u3055\u308c\u307e\u3059\uff0e<\/p>\n<\/div>\n<div id=\"__asciidoctor-preview-536__\" class=\"listingblock\">\n<div class=\"content\">\n<pre>$ :           #\u4f55\u3082\u3057\u306a\u3044\r\n$ : hoge\r\n$ : echo hoge\r\n$ : rm -rf *\r\n$ : $(hostname)  #\u30b3\u30de\u30f3\u30c9\u3082\u5c55\u958b\u305b\u305a\u4f55\u3082\u3057\u306a\u3044\r\n$ : `whoami`\r\n$ : hoge; echo fuga   #;\u306e\u5f8c\u306f\u89e3\u91c8\u3055\u308c\u308b\r\nfuga\r\n$ # hoge\r\n$ # hoge; echo fuga<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-540__\" class=\"paragraph\">\n<p>\u3053\u308c\u3092crontab\u306e\u982d\u306b\u66f8\u304f\u3068\u3053\u3046\u3044\u3046\u611f\u3058\u306b\u306a\u308a\u307e\u3059\uff0e<\/p>\n<\/div>\n<div id=\"__asciidoctor-preview-548__\" class=\"listingblock\">\n<div class=\"title\">crontab<\/div>\n<div class=\"content\">\n<pre>29 6 * * *  : cron subject; echo \"hello\"<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-556__\" class=\"listingblock\">\n<div class=\"title\">mail<\/div>\n<div class=\"content\">\n<pre>Subject: Cron &lt;matoken@T430s&gt; : cron subject; echo \"hello\"\r\n\r\nhello<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-560__\" class=\"paragraph\">\n<p>\u5c11\u3057\u308f\u304b\u308a\u3084\u3059\u304f\u306a\u308a\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_mail\">mail\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3059\u308b<\/h2>\n<div class=\"sectionbody\">\n<div id=\"__asciidoctor-preview-592__\" class=\"paragraph\">\n<p>\u3053\u308c\u306f\u3061\u3087\u3063\u3068\u53cd\u5247\u306a\u611f\u3058\u304c\u3059\u308b\u306e\u3067\u3059\u304c\u4ef6\u540d\u306b\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u7d50\u679c\u3092\u5165\u308c\u305f\u308a\uff0c\u982d\u306e\u90e8\u5206\u3082\u66f8\u304d\u63db\u3048\u305f\u3044\u5834\u5408\u306fcron\u3060\u3051\u3067\u306f\u3067\u304d\u306a\u3055\u305d\u3046\u306a\u306e\u3067mail\u30b3\u30de\u30f3\u30c9\u7d4c\u7531\u3067\u9001\u4fe1\u3057\u3066\u307f\u307e\u3059\uff0e\u4eca\u56demailutils\u306email\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u307e\u3057\u305f\u304c\uff0cbsd-mailx\u3084mutt\u7b49\u3005\u3082\u3082\u3061\u308d\u3093\u4f7f\u3048\u307e\u3059\uff0e<\/p>\n<\/div>\n<div id=\"__asciidoctor-preview-600__\" class=\"listingblock\">\n<div class=\"title\">crontab<\/div>\n<div class=\"content\">\n<pre>45 6 * * *  echo \"cron test\" | mail -s \"$(hostname)@$(whoami) cron Subject : $(date +\\%F)\" matoken+cron@example.com<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-608__\" class=\"listingblock\">\n<div class=\"title\">mail<\/div>\n<div class=\"content\">\n<pre>Subject: T430s@matoken cron Subject : 2018-09-13\r\nX-Mailer: mail (GNU Mailutils 3.4)\r\n\r\ncron test<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-612__\" class=\"paragraph\">\n<p>mail \u30b3\u30de\u30f3\u30c9\u306e -s \u30aa\u30d7\u30b7\u30e7\u30f3\u90e8\u5206\u304c\u4ef6\u540d\u306b\u306a\u308a\u307e\u3059\uff0e\u305d\u306e\u5f8c\u308d\u304c\u5b9b\u5148\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\uff0ebody\u306fcron\u306e\u51fa\u529b\u3092\u30d1\u30a4\u30d7\u304b\u3089\u53d7\u3051\u53d6\u308a\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_stderr\">STDERR \u304c\u5225\u30e1\u30fc\u30eb\u3067\u5c4a\u304f<\/h3>\n<div id=\"__asciidoctor-preview-642__\" class=\"paragraph\">\n<p>STDERR \u306e\u51fa\u529b\u304c\u3042\u3063\u305f\u5834\u5408cron\u3067\u30e1\u30fc\u30eb\u304c\u9001\u3089\u308c\u3066\u3057\u307e\u3044\u307e\u3059\uff0email\u30b3\u30de\u30f3\u30c9\u3068\u5408\u308f\u305b\u30661\u5ea6\u306b2\u901a\u5c4a\u304f\u3053\u3068\u306b\uff0e<br \/>\n\u5b9f\u884c\u30b3\u30de\u30f3\u30c9\u306e\u5f8c\u308d\u306b 2&gt;&amp;1 \u3092\u4ed8\u3051\u3066 STDERR \u3092 STDOUT \u306b\u6e21\u3057\u3066mail\u30b3\u30de\u30f3\u30c9\u3060\u3051\u306b\u3057\u307e\u3059\uff0e<\/p>\n<\/div>\n<div id=\"__asciidoctor-preview-650__\" class=\"listingblock\">\n<div class=\"title\">crontab<\/div>\n<div class=\"content\">\n<pre>45 6 * * *  echo \"cron test\" 2&gt;&amp;1 | mail -s \"$(hostname)@$(whoami) cron Subject : $(date +\\%F)\" matoken+cron@example.com<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"___2\">\u51fa\u529b\u304c\u306a\u304f\u3066\u3082\u30e1\u30fc\u30eb\u304c\u5c4a\u304f<\/h3>\n<div id=\"__asciidoctor-preview-690__\" class=\"paragraph\">\n<p>crontab \u306e\u5834\u5408\u30b3\u30de\u30f3\u30c9\u306e\u51fa\u529b\u304c\u306a\u3051\u308c\u3070\u30e1\u30fc\u30eb\u304c\u9001\u3089\u308c\u307e\u305b\u3093\u304c\uff0c\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3067\u306f NULL \u3067\u3082\u30e1\u30fc\u30eb\u304c\u9001\u4fe1\u3055\u308c\u307e\u3059\uff0e<br \/>\n\u672a\u89e3\u6c7a\uff0e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"___3\">\u4f59\u9332<\/h2>\n<div class=\"sectionbody\">\n<div class=\"sect2\">\n<h3 id=\"_cron\">cron\u3067\u4e00\u5207\u30e1\u30fc\u30eb\u3092\u9001\u308a\u305f\u304f\u306a\u3044<\/h3>\n<div id=\"__asciidoctor-preview-748__\" class=\"listingblock\">\n<div class=\"title\">\u5834\u5408crontab\u3067 MAILTO=&#8221;&#8221; \u3092\u8a2d\u5b9a\u3059\u308b<\/div>\n<div class=\"content\">\n<pre>MAILTO=\"\"<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"___4\">\u6307\u5b9a\u3057\u305f\u30b3\u30de\u30f3\u30c9\u3060\u3051\u30e1\u30fc\u30eb\u3092\u9001\u308a\u305f\u304f\u306a\u3044<\/h3>\n<div id=\"__asciidoctor-preview-806__\" class=\"listingblock\">\n<div class=\"title\">STDOUT \u3068 STDERR \u3092 \/dev\/null \u306b\u6368\u3066\u308b<\/div>\n<div class=\"content\">\n<pre>20 6 * * *  echo \"cron subject\" &gt; \/dev\/null 2&gt;&amp;1<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"___5\">\u30e1\u30fc\u30eb\u304c\u5c4a\u304b\u306a\u3044<\/h3>\n<div id=\"__asciidoctor-preview-836__\" class=\"paragraph\">\n<p>\/var\/spool\/mail\/\u30e6\u30fc\u30b6\u540d \u306e\u30ed\u30fc\u30ab\u30eb\u306b\u306f\u30e1\u30fc\u30eb\u304c\u3069\u3068\u304f\u3051\u3069\uff0c\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3082\u5c4a\u304b\u306a\u3044\u5834\u5408\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u306e\u8a2d\u5b9a\u304c\u51fa\u6765\u3066\u3044\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff0e\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0(sSMTP\/msmtp\u7b49\u306f\u30c7\u30fc\u30e2\u30f3\u304c\u8d77\u52d5\u3057\u306a\u3044\u306e\u3067\u30e1\u30fc\u30eb\u3092\u53d7\u3051\u53d6\u3089\u305a\u9001\u4fe1\u3059\u308b\u3060\u3051\u306a\u3089\u304a\u3059\u3059\u3081)\u3092\u8a2d\u5b9a\u3057\u3066\u304b\u3089\u518d\u5ea6\u8a66\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff0e<\/p>\n<\/div>\n<div id=\"__asciidoctor-preview-844__\" class=\"listingblock\">\n<div class=\"title\">\u74b0\u58831<\/div>\n<div class=\"content\">\n<pre>$ man cron | grep -m1 cron\r\n       cron - daemon to execute scheduled commands (Vixie Cron)\r\n$ dpkg-query -W cron mailutils\r\ncron    3.0pl1-128.1ubuntu1\r\nmailutils       1:3.4-1\r\n$ lsb_release -d\r\nDescription:    Ubuntu 18.04.1 LTS\r\n$ uname -m\r\nx86_64<\/pre>\n<\/div>\n<\/div>\n<div id=\"__asciidoctor-preview-852__\" class=\"listingblock\">\n<div class=\"title\">\u74b0\u58832<\/div>\n<div class=\"content\">\n<pre>$ man cron | grep -m1 cron\r\n       cron - \u4e88\u5b9a\u3055\u308c\u305f\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u30c7\u30fc\u30e2\u30f3(Vixie Cron)\r\n$ dpkg-query -W cron mailutils\r\ncron    3.0pl1-130\r\nmailutils       1:3.4-1+b1\r\n$ lsb_release -d\r\nDescription:    Debian GNU\/Linux unstable (sid)\r\n$ uname -m\r\nx86_64<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>crontab \u3067\u5b9f\u884c\u3055\u308c\u305f\u30b3\u30de\u30f3\u30c9\u306e\u51fa\u529b\u306f\u30e1\u30fc\u30eb\u3067\u9001\u3089\u308c\u307e\u3059\u304c\uff0c\u3053\u306e\u3068\u304d\u306e\u4ef6\u540d\u306f\u300cCron &lt;\u30e6\u30fc\u30b6\u540d@\u30db\u30b9\u30c8\u540d&gt; \u5b9f\u884c\u30b3\u30de\u30f3\u30c9\u300d\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\uff0e crontab \u4f8b 15 7 * * * echo &#8220;c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"webmentions_disabled_pings":false,"webmentions_disabled":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[372,7,6,199,63],"tags":[398,399,110,400],"class_list":["post-2116","post","type-post","status-publish","format-standard","hentry","category-bionic-beaver18-04lts","category-debian-linux","category-linux","category-sid","category-ubuntu","tag-cron","tag-crontab","tag-mail","tag-mailutils"],"_links":{"self":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/2116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/comments?post=2116"}],"version-history":[{"count":0,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/2116\/revisions"}],"wp:attachment":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/media?parent=2116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/categories?post=2116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/tags?post=2116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}