{"id":22440,"date":"2023-05-11T10:48:44","date_gmt":"2023-05-11T01:48:44","guid":{"rendered":"https:\/\/labs.gree.jp\/blog\/?p=22440"},"modified":"2023-05-11T10:48:44","modified_gmt":"2023-05-11T01:48:44","slug":"bpftrace%e3%81%a7%e6%b7%b1%e5%a4%9c%e3%81%ab%e3%83%97%e3%83%ad%e3%82%bb%e3%82%b9%e3%82%92kill%e3%81%97%e3%81%9f%e7%8a%af%e4%ba%ba%e3%82%92%e7%89%b9%e5%ae%9a%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2023\/05\/22440\/","title":{"rendered":"bpftrace\u3067\u6df1\u591c\u306b\u30d7\u30ed\u30bb\u30b9\u3092kill\u3057\u305f\u72af\u4eba\u3092\u7279\u5b9a\u3059\u308b"},"content":{"rendered":"<p>\u30a4\u30f3\u30d5\u30e9\u306e\u3044\u308f\u307b\u308a\uff08egmc\uff09\u3067\u3059\u3002<\/p>\n<p>eBPF\u3092\u5229\u7528\u3057\u305f\u30d7\u30ed\u30c0\u30af\u30c8\u3068\u3057\u3066\u306fCilium\u306a\u3069\u304ccloud native\u306a\u6587\u8108\u3068\u3057\u3066\u76db\u308a\u4e0a\u304c\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u4e00\u65b9\u3067BCC Tools\u3084bpftace\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u5185\u90e8\u306e\u304b\u3086\u3044\u3068\u3053\u308d\u306b\u624b\u304c\u5c4a\u304f\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066\u8eab\u8fd1\u306a\u8ab2\u984c\u89e3\u6c7a\u306b\u30ab\u30b8\u30e5\u30a2\u30eb\u306b\u5f79\u7acb\u3064\u30c4\u30fc\u30eb\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u30c4\u30fc\u30eb\u306f\u5b9f\u969b\u306b\u4fbf\u5229\u3067\u306f\u3042\u308b\u3082\u306e\u306e\u73fe\u5b9f\u4e16\u754c\u3067\u306e\u4e8b\u4f8b\u3092\u305d\u308c\u307b\u3069\u898b\u304b\u3051\u306a\u3044\u3068\u3044\u3046\u306e\u3082\u3042\u308a\u3001\u300c\u3053\u3093\u306a\u611f\u3058\u3067\u5f79\u306b\u7acb\u3063\u305f\u300d\u3068\u3044\u3046\u4e8b\u4f8b\u3092\u30ab\u30b8\u30e5\u30a2\u30eb\u306b\u7d39\u4ecb\u3057\u3066\u3044\u304f\u306e\u3082\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u306b\u3068\u3063\u3066\u6709\u7528\u3067\u306f\u306a\u3044\u304b\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306fOS\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u306b\u95a2\u9023\u3057\u3066\u767a\u751f\u3057\u305f\u554f\u984c\u306e\u8abf\u67fb\u306bbpftrace\u304c\u5f79\u7acb\u3063\u305f\u3068\u3044\u3046\u304a\u8a71\u3092\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u74b0\u5883<\/p>\n<ul>\n<li>Ubuntu 20.04.6 LTS<\/li>\n<li>bpftrace v0.9.4<\/li>\n<\/ul>\n<h2>\u767a\u751f\u3057\u305f\u4e8b\u8c61<\/h2>\n<p>GREE\u306e\u30af\u30e9\u30a6\u30c9\u74b0\u5883\u3067\u5229\u7528\u3057\u3066\u3044\u308b<a href=\"https:\/\/labs.gree.jp\/blog\/2017\/05\/16483\/\">\u30b7\u30b9\u30c6\u30e0\u306e\u30a2\u30e9\u30fc\u30c8\u306e\u914d\u9001\u3092\u884c\u3046\u30ef\u30fc\u30ab\u30fc<\/a>\uff08Yusura\uff09\u306fRuby\u3067\u5b9f\u88c5\u3055\u308c\u3066\u304a\u308a\u3001<a href=\"https:\/\/github.com\/ruby-shoryuken\/shoryuken\">Shoryuken<\/a>\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u3061\u3089\u306e\u30ef\u30fc\u30ab\u30fc\u306e\u52d5\u4f5c\u74b0\u5883\u3092Ubuntu 18.04 Bionic\u304b\u308920.04 Focal\u306b\u79fb\u884c\u3057\u305f\u3068\u3053\u308d\u3001\u6df1\u591c0\u6642\u306b\u5168\u30ef\u30fc\u30ab\u30fc\u30d7\u30ed\u30bb\u30b9\u304c\u30c0\u30a6\u30f3\u3059\u308b\u3068\u3044\u3046\u4e8b\u8c61\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-22463\" src=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2023\/05\/yusura-down-image-600x333.jpg\" alt=\"yusura-down-image\" width=\"600\" height=\"333\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2023\/05\/yusura-down-image-600x333.jpg 600w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2023\/05\/yusura-down-image-830x460.jpg 830w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2023\/05\/yusura-down-image-276x153.jpg 276w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2023\/05\/yusura-down-image-768x426.jpg 768w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2023\/05\/yusura-down-image.jpg 1400w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>\u5e78\u3044\u3053\u3061\u3089\u306e\u74b0\u5883\u306f\u30ad\u30e5\u30fc\u306e\u6ede\u7559\u5177\u5408\u306b\u5fdc\u3058\u3066\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30eb\u3092\u884c\u3046\u8a2d\u5b9a\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u65b0\u898f\u306b\u8d77\u52d5\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u51e6\u7406\u3092\u7d99\u7d9a\u3057\u305f\u305f\u3081\u3001\u30a2\u30e9\u30fc\u30c8\u306f\u9cf4\u3063\u305f\u3082\u306e\u306e\u5927\u304d\u306a\u5f71\u97ff\u306f\u306a\u304f\u30b5\u30fc\u30d3\u30b9\u81ea\u4f53\u306f\u7d99\u7d9a\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u4e00\u6b21\u5bfe\u5fdc\u3068\u3057\u3066\u306fBionic\u3078\u306e\u5207\u308a\u623b\u3057\u3092\u5b9f\u65bd\u3057\u3001staging\u76f8\u5f53\u306e\u691c\u8a3c\u74b0\u5883\u3067\u6539\u3081\u3066\u539f\u56e0\u8abf\u67fb\u3092\u884c\u3046\u3053\u3068\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30ed\u30b0\u306e\u8abf\u67fb<\/h2>\n<p>\u30ef\u30fc\u30ab\u30fc\u306e\u30ed\u30b0\u3001syslog\u306a\u3069\u3092\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001\u4e8b\u8c61\u767a\u751f\u524d\u5f8c\u3067logrotate\u304c\u884c\u308f\u308c\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\n\u5f53\u8a72\u30ef\u30fc\u30ab\u30fc\u3082\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\u3092\u884c\u3063\u3066\u304a\u308a\u3001\u304b\u3064\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092\u63b4\u307f\u76f4\u3059\u305f\u3081\u306bpostrotate\u3067\u518d\u8d77\u52d5\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u308b\u306e\u3067\u72b6\u6cc1\u3068\u3057\u3066\u306f\u3053\u306e\u51e6\u7406\u304c\u3042\u3084\u3057\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u30ef\u30fc\u30ab\u30fc\u306f2015\u5e74\u9803\u304b\u3089\u4f7f\u308f\u308c\u3066\u304a\u308a\u5b9f\u88c5\u3082\u3084\u3084\u53e4\u304f\u3001\u30c7\u30fc\u30e2\u30f3\u7ba1\u7406\u306f\u7d20\u6734\u306astart\/stop\u7528\u306e\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>start\u30b9\u30af\u30ea\u30d7\u30c8\n<ul>\n<li>EC2\u306e\u30bf\u30b0\u60c5\u5831\u306a\u3069\u3092\u3082\u3068\u306b\u5b9f\u884c\u74b0\u5883\u3092\u5224\u5b9a\u3057\u3066\u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a\u3059\u308b<\/li>\n<li>S3\u304b\u3089\u8ffd\u52a0\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u914d\u7f6e\u3059\u308b<\/li>\n<li>Shoryuken\u306e-d\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u3088\u308a\u30d7\u30ed\u30bb\u30b9\u3092\u30c7\u30fc\u30e2\u30ca\u30a4\u30ba\u3057\u3066\u8d77\u52d5\u3001pid\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210\u3059\u308b<\/li>\n<\/ul>\n<\/li>\n<li>stop\u30b9\u30af\u30ea\u30d7\u30c8\n<ul>\n<li>pid\u30d5\u30a1\u30a4\u30eb\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3001\u5bfe\u8c61\u30d7\u30ed\u30bb\u30b9\u306b\u5bfe\u3057\u3066SIGUSR1\uff08Shoryuken\u3067\u306esoft stop\u76f8\u5f53\uff09\u3092\u9001\u308b\n<ul>\n<li>\u4e00\u5b9a\u6642\u9593\u7d4c\u904e\u3057\u30d7\u30ed\u30bb\u30b9\u304c\u307e\u3060\u8d77\u52d5\u3057\u3066\u3044\u308b\u5834\u5408\u306fSIGTERM\u3092\u9001\u308b<\/li>\n<\/ul>\n<\/li>\n<li>pid\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3059\u308b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u672c\u6765\u30ef\u30fc\u30ab\u30fc\u306f\u518d\u8d77\u52d5\u306a\u3069\u3092\u671f\u5f85\u3057\u3066\u30c7\u30fc\u30e2\u30f3\u7ba1\u7406\u3092systemd\u3084supervisord\u306a\u3069\u306b\u4efb\u305b\u308b\u306e\u304c\u826f\u3044\u306e\u3067\u3059\u304c\u3001\u65e2\u5b58\u306e\u524d\u51e6\u7406\u304c\u3084\u3084\u9762\u5012\u306a\u306e\u3068\u30ef\u30fc\u30ab\u30fc\u306b\u554f\u984c\u304c\u3042\u3063\u3066\u7a81\u7136\u6b7b\u3059\u308b\u3001\u307f\u305f\u3044\u306a\u30b1\u30fc\u30b9\u3082\u3042\u307e\u308a\u306a\u304b\u3063\u305f\u306e\u3067\u305d\u306e\u307e\u307e\u4f7f\u308f\u308c\u3066\u7d9a\u3051\u3066\u304d\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u306d\u3002<\/p>\n<p>\u30ef\u30fc\u30ab\u30fc\u306e\u30ed\u30b0\u4e0a\u3092\u78ba\u8a8d\u3059\u308b\u3068postrotate\u3067\u3053\u306estop\/start\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u5b9f\u884c\u3055\u308c\u3001\u6b63\u5e38\u306bSIGUSR1\u3092\u53d7\u3051\u53d6\u3063\u3066\u306e\u30d7\u30ed\u30bb\u30b9\u505c\u6b62\u3001\u8d77\u52d5\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u304c\u3001\u8d77\u52d5\u3057\u305f\u76f4\u5f8c\u306bSIGTERM\u3092\u53d7\u3051\u3066\u30d7\u30ed\u30bb\u30b9\u304c\u505c\u6b62\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057logrotate\u3092 -f\u30aa\u30d7\u30b7\u30e7\u30f3\u3064\u304d\u3067\u624b\u52d5\u3067\u5b9f\u884c\u3057\u3066\u307f\u3066\u3082postrotate\u306b\u3088\u308b\u518d\u8d77\u52d5\u306f\u6b63\u5e38\u306b\u5b9f\u65bd\u3055\u308c\u3001SIGTERM\u306f\u3069\u3053\u304b\u3089\u3082\u98db\u3093\u3067\u3053\u305a\u3001\u30ef\u30fc\u30ab\u30fc\u306f\u52d5\u4f5c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>stop\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3082SIGTERM\u306f\u6271\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u30ed\u30b0\u306b\u8a18\u9332\u3055\u308c\u3066\u3044\u308bSIGTERM\u306f\u8d77\u52d5\u5f8c\u306b\u53d7\u3051\u53d6\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u3084\u306f\u308a\u3069\u3053\u304b\u5225\u306e\u30d7\u30ed\u30bb\u30b9\u304b\u3089\u9001\u51fa\u3055\u308c\u305f\u3082\u306e\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>logrotate\u307e\u308f\u308a\u306e\u51e6\u7406\u3092\u7591\u3044\u3064\u3064\u3082\u78ba\u8a3c\u3092\u5f97\u308b\u305f\u3081\u3001SIGTERM\u306e\u9001\u51fa\u5143\u3092\u7279\u5b9a\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2>bpftrace\u306b\u3088\u308b\u8abf\u67fb<\/h2>\n<p>Shoryuken\u3067\u306f<a href=\"https:\/\/github.com\/ruby-shoryuken\/shoryuken\/blob\/f94f0707c1acc8ddb772b5fc98787141a68462c8\/lib\/shoryuken\/runner.rb#L23\">\u30b7\u30b0\u30ca\u30eb\u3092trap\u3067\u51e6\u7406\u3057\u3066\u3044\u307e\u3059<\/a>\u304c\u3001\u9001\u51fa\u5143\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u3053\u3053\u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3053\u3067bpftrace\u3067\u30ab\u30fc\u30cd\u30eb\u306esyscall\u306b\u8a2d\u5b9a\u3055\u308c\u305ftracepoint\u306b\u30d5\u30c3\u30af\u3057\u3066\u30b7\u30b0\u30ca\u30eb\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u884c\u3063\u3066\u304f\u308c\u308b\u305d\u306e\u3082\u306e\u305a\u3070\u308a\u306abpftrace\u30c4\u30fc\u30eb\uff08<a href=\"https:\/\/github.com\/iovisor\/bpftrace\/blob\/master\/tools\/killsnoop.bt\">killsnoop.bt<\/a>\uff09\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u306e\u3067\u3053\u308c\u3092\u305d\u306e\u307e\u307e\u4f7f\u3044\u307e\u3059\uff08BCC Tools\u306e\u4e00\u90e8\u3068\u3057\u3066\u540c\u3058\u304fkillsnoop\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306ffocal\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308bBCC\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u53e4\u304f\u6b8b\u5ff5\u306a\u304c\u3089\u305d\u306e\u307e\u307e\u3067\u306f\u52d5\u304d\u307e\u305b\u3093\uff09\u3002<\/p>\n<p>\u4eca\u56de\u306f\u6642\u9593\u304c\u6df1\u591c0\u6642\u76f4\u5f8c\u3068\u3044\u3046\u3053\u3068\u304c\u308f\u304b\u3063\u3066\u3044\u308b\u306e\u3067\u3001<\/p>\n<pre class=\"lang:default decode:true\">timeout $timeout killsnoop.bt<\/pre>\n<p>\u306e\u3088\u3046\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3092cron\u306723:59\u304b\u3089\u4e00\u5b9a\u6642\u9593\u5b9f\u884c\u3057\u3066\u30ed\u30b0\u306b\u8a18\u9332\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u7d50\u679c\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ed\u30b0\u7fa4\u304c\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>killsnoop.bt\u306e\u30ed\u30b0<\/p>\n<pre class=\"lang:default decode:true\" title=\"killsnoop.bt\u306e\u30ed\u30b0\">00:00:01  466297 kill             10   439956 0\n00:00:04  1      systemd          15   466335 0\n00:00:04  1      systemd          18   466335 0<\/pre>\n<p>logrotate.service\u306e\u30ed\u30b0<\/p>\n<pre class=\"wrap:true lang:default decode:true \" title=\"logrotate.service\u306e\u30ed\u30b0\">Mar 23 00:00:01 ip-10-104-177-250 sudo[466294]:     root : TTY=unknown ; PWD=\/ ; USER=yusura ; COMMAND=\/usr\/bin\/kill -USR1 439956<\/pre>\n<p>\u30ef\u30fc\u30ab\u30fc\uff08Yusura\uff09\u306e\u30ed\u30b0<\/p>\n<pre class=\"lang:default decode:true\" title=\"\u30ef\u30fc\u30ab\u30fc\uff08Yusura\uff09\u306e\u30ed\u30b0\">[2023-03-22 13:47:15] INFO WEBrick::HTTPServer#start: pid=439956 port=9130\n2023-03-22T15:00:01Z 439956 TID-46k INFO: Received USR1, will soft shutdown down\n2023-03-22T15:00:01Z 439956 TID-46k INFO: Shutting down\n...\n2023-03-22T15:00:05Z 466335 TID-46k INFO: Starting\n[2023-03-23 00:00:05] INFO  WEBrick 1.6.0\n[2023-03-23 00:00:05] INFO  ruby 2.7.0 (2019-12-25) [x86_64-linux-gnu]\n2023-03-22T15:00:05Z 466335 TID-46k INFO: Received TERM, will shutdown\n[2023-03-23 00:00:05] INFO  WEBrick::HTTPServer#start: pid=466335 port=9130\n2023-03-22T15:00:05Z 466335 TID-46k INFO: Shutting down\n[2023-03-23 00:00:05] INFO  going to shutdown ...\n[2023-03-23 00:00:05] INFO  WEBrick::HTTPServer#start done.<\/pre>\n<p>\u6700\u521d\u306ekill\u30b3\u30de\u30f3\u30c9\u306b\u3088\u308bSIGUSR1\u304clogrotate\u306epostrotate\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u5b9f\u884c\u3055\u308c\u305f\u3082\u306e\u3067\u3001\u305d\u306e\u5f8c\u8d77\u52d5\u3057\u305f\u30ef\u30fc\u30ab\u30fc\u306e\u30d7\u30ed\u30bb\u30b9\uff08466335\uff09\u306b\u5bfe\u3057\u3066systemd\u304b\u3089SIGTERM\u304c\u9001\u51fa\u3055\u308c\u3066\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u304a\u3084\u3001\u4f7f\u3063\u3066\u306a\u3044\u306f\u305a\u306esystemd\u3067\u3059\u306d\u30fb\u30fb\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067systemd\u306e\u30b5\u30fc\u30d3\u30b9\u307e\u308f\u308a\u3092\u6539\u3081\u3066\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001logrotate\u30b5\u30fc\u30d3\u30b9\u304cbionic\u3067\u306fcron\u3067\u52d5\u4f5c\u3057\u3066\u3044\u305f\u3082\u306e\u304cfocal\u3067\u306fsystemd.timer\u306b\u5207\u308a\u66ff\u308f\u3063\u3066\u304a\u308a\u3001\u305d\u306e\u305f\u3081\u306b\u4eca\u56de\u306e\u4e8b\u8c61\u306b\u7e4b\u304c\u3063\u305f\u3001\u3068\u3044\u3046\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u539f\u56e0\u306flogrotate\u304csystemd\u3067\u52d5\u4f5c\u3059\u308b\u3053\u3068\u306b\u3088\u308b\u6319\u52d5\u306e\u5909\u5316<\/h2>\n<p>focal\u306elogrotate\u30b5\u30fc\u30d3\u30b9\u306fType=oneshot\u306esystemd.service\u3068\u3057\u3066\u52d5\u4f5c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30b5\u30fc\u30d3\u30b9\u304csystemd.timer\u306eOnCalendar=daily\u3068\u3044\u3046\u5b9a\u7fa9\u306b\u3088\u3063\u3066cron.daily\u76f8\u5f53\u306e\u30eb\u30fc\u30eb\u3068\u3057\u3066\u8d77\u52d5\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Type=oneshot\u306e\u30b5\u30fc\u30d3\u30b9\u306f\u5b9f\u884c\u304c\u5b8c\u4e86\u3059\u308b\u3068<a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd.kill.html#KillMode=\">KillMode<\/a>\u306e\u6307\u5b9a\u306b\u5f93\u3063\u3066\u5b9f\u884c\u4e2d\u306e\u30d7\u30ed\u30bb\u30b9\u306bkill\u30b7\u30b0\u30ca\u30eb\u3092\u9001\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p>logrotate.service\u30e6\u30cb\u30c3\u30c8\u306b\u306f\u3000KillMode\u306e\u6307\u5b9a\u306f\u306a\u3044\u305f\u3081\u30c7\u30d5\u30a9\u30eb\u30c8\u306econtrol-group\uff08unit\u306ecgroup\u306b\u6240\u5c5e\u3059\u308b\u3059\u3079\u3066\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u5bfe\u8c61\u3068\u3059\u308b\u30e2\u30fc\u30c9\uff09\u3067\u52d5\u4f5c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306b\u3088\u308a\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u6d41\u308c\u3067\u4eca\u56de\u306e\u4e8b\u8c61\u304c\u767a\u751f\u3057\u3066\u3044\u307e\u3057\u305f<\/p>\n<ul>\n<li>logrotate\u30b5\u30fc\u30d3\u30b9\u304ctimer\u306b\u3088\u308a\u8d77\u52d5\u3055\u308c\u308b<\/li>\n<li>logrotate\u306epostrotate\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u3088\u308a\u30ef\u30fc\u30ab\u30fc\uff08Yusura\uff09\u304c\u518d\u8d77\u52d5\u3055\u308c\u308b\n<ul>\n<li>\u30ef\u30fc\u30ab\u30fc\u306f\u3053\u306e\u6642\u70b9\u3067Ruby\u306e<a href=\"https:\/\/docs.ruby-lang.org\/ja\/latest\/method\/Process\/m\/daemon.html\">Process.daemon<\/a>\u306b\u3088\u308a\u30c7\u30fc\u30e2\u30ca\u30a4\u30ba\u304c\u884c\u308f\u308c\u3001logrotate\u306e\u30d7\u30ed\u30bb\u30b9\u30b0\u30eb\u30fc\u30d7\u304b\u3089\u5206\u96e2\u3055\u308c\u308b<\/li>\n<\/ul>\n<\/li>\n<li>logrotate\u51e6\u7406\u304c\u7d42\u4e86\u3057\u3001unit\u306ecgroup\u306b\u6240\u5c5e\u3059\u308b\u30d7\u30ed\u30bb\u30b9\u306b\u5bfe\u3057\u3066SIGTERM\u304c\u9001\u51fa\u3055\u308c\u308b\u3053\u3068\u306b\u3088\u308a\u30ef\u30fc\u30ab\u30fc\u304c\u505c\u6b62\u3059\u308b\n<ul>\n<li>\u30ef\u30fc\u30ab\u30fc\u306f\u30d7\u30ed\u30bb\u30b9\u30b0\u30eb\u30fc\u30d7\u304b\u3089\u306f\u5206\u96e2\u3067\u304d\u3066\u3044\u308b\u3082\u306e\u306ecgroup\u306f\u305d\u306e\u307e\u307e\u306a\u306e\u3067\u3001systemd\u304b\u3089\u505c\u6b62\u30b7\u30b0\u30ca\u30eb\u3092\u9001\u308b\u5bfe\u8c61\u3068\u3057\u3066\u8a8d\u8b58\u3055\u308c\u308b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>bionic\u307e\u3067\u3067\u306flogrotate\u306fcron\u304b\u3089\u8d77\u52d5\u3055\u308c\u308b\u305f\u3081\u3001logrotate\u5b9f\u884c\u5f8c\u306e\u30ef\u30fc\u30ab\u30fc\u30d7\u30ed\u30bb\u30b9\u3082cgroup\u3068\u3057\u3066\u306fcron.service\u30e6\u30cb\u30c3\u30c8\u306e\u3082\u306e\u306b\u5c5e\u3057\u3066\u304a\u308a\u3001cron\u304c\u751f\u304d\u7d9a\u3051\u3066\u3044\u308b\u9650\u308a\u8d77\u52d5\u3057\u7d9a\u3051\u308b\u3053\u3068\u304c\u51fa\u6765\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057focal\u3067\u306flogrotate\u81ea\u8eab\u304csystemd.timer\u3067\u8d77\u52d5\u3055\u305b\u3089\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u305f\u3081\u4e0a\u8a18\u306e\u3088\u3046\u306a\u6d41\u308c\u3067logrotate\u7d42\u4e86\u5f8c\u306b\u3001\u30ef\u30fc\u30ab\u30fc\u306e\u30d7\u30ed\u30bb\u30b9\u306b\u3082SIGTERM\u304c\u9001\u51fa\u3055\u308c\u3001\u7d50\u679c\u3059\u3079\u3066\u306e\u30ef\u30fc\u30ab\u30fc\u304clogrotate\u306e\u6642\u9593\u3067\u505c\u6b62\u3059\u308b\u3001\u3068\u3044\u3046\u4e8b\u8c61\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u3068\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u539f\u56e0\u3092\u8e0f\u307e\u3048\u3066\u306e\u5bfe\u5fdc<\/h2>\n<p>\u539f\u56e0\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u9577\u304f\u4f7f\u308f\u308c\u3066\u304d\u305f\u30ef\u30fc\u30ab\u30fc\u306estop\/start\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5ec3\u6b62\u3057\u3001systemd\u3067\u30c7\u30fc\u30e2\u30f3\u7ba1\u7406\u3059\u308b\u65b9\u5f0f\u306b\u5909\u66f4\u3059\u308b\u3053\u3068\u3067\u5bfe\u5fdc\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u305d\u306e\u307e\u307e\u6d41\u7528\u3057\u3066\u3001systemd.service\u3092type=forking\u3067\u5b9a\u7fa9\u3059\u308b\u306e\u304c\u3082\u3063\u3068\u3082\u624b\u6570\u306e\u5c11\u306a\u3044\u5bfe\u5fdc\u306b\u306a\u308a\u305d\u3046\u3067\u3057\u305f\u304c\u3001\u305b\u3063\u304b\u304f\u624b\u3092\u5165\u308c\u308b\u6a5f\u4f1a\u3067\u3082\u3042\u308b\u306e\u3067\u4eca\u56de\u306f\u4ee5\u4e0b\u306e\u5bfe\u5fdc\u3092\u884c\u3046\u3053\u3068\u3067type=simple\u306e\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u65e2\u5b58\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u540c\u69d8\u306e\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u74b0\u5883\u5909\u6570\u306e\u8a2d\u5b9a -&gt;\u00a0 \u30c7\u30d7\u30ed\u30a4\u51e6\u7406\u306e\u904e\u7a0b\u3067env\u30d5\u30a1\u30a4\u30eb\u3092\u52d5\u7684\u306b\u751f\u6210\u3057EnvironmentFile\u3067\u6307\u5b9a<\/li>\n<li>\u8ffd\u52a0\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9 -&gt; ExecStartPre\u3067\u5b9f\u65bd<\/li>\n<li>Stop\u6642\u306bSIGUSR1\u3092\u9001\u308a\u4e00\u5b9a\u6642\u9593\u7d4c\u904e\u5f8c\u306b\u751f\u304d\u3066\u3044\u305f\u3089kill\u3059\u308b -&gt; KillSignal=SIGUSR1\u3068\u3057TimeoutStopSec\u3092\u6307\u5b9a<\/li>\n<\/ul>\n<p>\u73fe\u4ee3\u306esystemd.serive\u306funit\u30d5\u30a1\u30a4\u30eb\u4e00\u3064\u3067\u7d30\u304b\u3044\u6319\u52d5\u3092\u6307\u5b9a\u3067\u304d\u308b\u306e\u3067\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n<p>\u3053\u306e\u5bfe\u5fdc\u306b\u3088\u308a\u30ef\u30fc\u30ab\u30fc\u30d7\u30ed\u30bb\u30b9\u306fsystemd\u7ba1\u7406\u3068\u306a\u308a\u3001logrotate\u51e6\u7406\u5f8c\u3082\u554f\u984c\u306a\u304f\u51e6\u7406\u3092\u7d99\u7d9a\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u306e\u3067\u3001focal\u3078\u306e\u79fb\u884c\u3082\u5b8c\u4e86\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3057\u305f\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<ul>\n<li>\u610f\u56f3\u305b\u306c\u30d7\u30ed\u30bb\u30b9\u306e\u505c\u6b62\u539f\u56e0\u3068\u306a\u3063\u305fSIGTERM\u306e\u9001\u51fa\u5143\u3092\u8abf\u3079\u308b\u305f\u3081\u306bbpftrace\u3092\u5229\u7528\u3057\u307e\u3057\u305f<\/li>\n<li>Ubuntu\u3067\u30b7\u30b9\u30c6\u30e0\u306e\u6319\u52d5\u8abf\u67fb\u306beBPF\u3092\u5229\u7528\u3057\u305f\u3044\u5834\u5408bpftrace\u304c\u4fbf\u5229\u3067\u3059<\/li>\n<li>\u73fe\u4ee3\u306e\u30d7\u30ed\u30bb\u30b9\u30c7\u30fc\u30e2\u30f3\u5316\u306f\u7d20\u6734\u306a\u30d7\u30ed\u30bb\u30b9\u5206\u96e2\u3060\u3051\u3067\u306f\u4e0d\u5341\u5206\u306a\u306e\u3067systemd\u306a\u3069\u306b\u307e\u304b\u305b\u3066\u3044\u304d\u307e\u3057\u3087\u3046<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u30a4\u30f3\u30d5\u30e9\u306e\u3044\u308f\u307b\u308a\uff08egmc\uff09\u3067\u3059\u3002 eBPF\u3092\u5229\u7528\u3057\u305f\u30d7\u30ed\u30c0\u30af\u30c8\u3068\u3057\u3066\u306fCilium\u306a\u3069\u304ccloud native\u306a\u6587\u8108\u3068\u3057\u3066\u76db\u308a\u4e0a\u304c\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u4e00\u65b9\u3067BCC Tools\u3084bpftace\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u5185\u90e8\u306e\u304b\u3086\u3044\u3068\u3053\u308d [&hellip;]<\/p>\n","protected":false},"author":164,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[223,22],"class_list":["post-22440","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-ebpf","tag-22"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/22440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=22440"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/22440\/revisions"}],"predecessor-version":[{"id":22487,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/22440\/revisions\/22487"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=22440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=22440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=22440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}