{"id":1229,"date":"2014-09-12T16:59:18","date_gmt":"2014-09-12T16:59:18","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1229"},"modified":"2018-05-06T09:39:09","modified_gmt":"2018-05-06T01:39:09","slug":"nginx-502-bad-gateway-error","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1229.html","title":{"rendered":"Nginx 502 Bad Gateway error"},"content":{"rendered":"<p>\u4eca\u5929\u4e0a\u534811\u70b9\u5de6\u53f3\u7684\u65f6\u5019\u5728\u8bbf\u95ee\u81ea\u5df1\u7684\u7f51\u7ad9\u65f6\u51fa\u73b0\u4e86502 Bad Gateway\u7684\u9519\u8bef\uff0c\u987f\u65f6\u6709\u70b9\u614c\uff08\u4e0d\u4f1a\u88ab\u9ed1\u4e86\u5427\uff1f\u867d\u7136\u8bf4\u6211\u77e5\u9053LNMP\u4e00\u952e\u5b89\u88c5\u5305\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u8bbe\u7f6e\u4e0d\u662f\u5f88\u5b89\u5168\uff0c\u4f46\u4e5f\u4e0d\u81f3\u4e8e\u8fd9\u6837\u5427\uff1f\u8d77\u7801\u6211\u88c5\u7684\u662f\u6700\u65b0\u7248\u7684WordPress\uff0c\u800c\u4e14\u6ca1\u6709\u88c5\u4efb\u4f55\u6709\u6f0f\u6d1e\u7684\u63d2\u4ef6\uff1b\u5e76\u4e14\u5728\u7f51\u7ad9\u76ee\u5f55\u4e0b\u9762\u6ca1\u6709\u653e\u4ec0\u4e48\u654f\u611f\u4fe1\u606f\u3001\u5907\u4efd\u7b49\u5b58\u5728\u660e\u663e\u6f0f\u6d1e\u7684\u6587\u4ef6\uff1b\u6700\u540e\u7684\u6700\u540e\uff0c\u6211\u4e5f\u6253\u7b97\u5728\u8fd9\u4e2a\u5468\u672b\u62bd\u51fa\u65f6\u95f4\u6765\u8bbe\u7f6e\/\u4fee\u6539\u4e00\u4e0b\u90a3\u51e0\u4e2a\u53ef\u80fd\u5b58\u5728\u95ee\u9898\u7684\u914d\u7f6e\u6587\u4ef6\u7684(php.ini\/nginx.conf\u7b49\u2026\u2026)\uff0c\u8279\uff0c\u5148\u597d\u597d\u5206\u6790\u4e0b\u539f\u56e0\u5427\uff0c\u4e5f\u4e0d\u4e00\u5b9a\u662f\u88ab\u9ed1\u4e86\uff0c\u53cd\u6b63\u5c31\u7f51\u7ad9\u65e0\u6cd5\u6b63\u5e38\u8bbf\u95ee\u8fd9\u4e00\u70b9\u5df2\u7ecf\u8ba9\u6211\u5f88\u751f\u6c14\u4e86\uff01\uff09<\/p>\n<p>\u9519\u8bef\u622a\u56fe\uff1a<\/p>\n<p><a href=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/09\/502_error.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1230 aligncenter\" src=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/09\/502_error.png\" alt=\"502_error\" width=\"286\" height=\"106\" \/><\/a><\/p>\n<p>\u4ee5\u201c\u5916\u4e8b\u7edd\u4e0d\u95ee\u767e\u5ea6\uff0c\u5185\u4e8b\u4e0d\u95eeGoogle\u201d\u7684\u539f\u5219\u8fdb\u884c\u641c\u7d22\uff08\u56e0\u4e3aGoogle\u5df2\u7ecf\u88ab\u5899\u4e86\u6709\u597d\u4e00\u6bb5\u65f6\u95f4\u4e86\uff0c\u6240\u4ee5\u73b0\u5728\u4e00\u822c\u4f7f\u7528aol.com\u3001yahoo.com\u548cbing.com\u6765\u66ff\u4ee3Google\u641c\u7d22\uff09\uff0c\u8fd9\u79cd\u9519\u8bef\u5176\u5b9e\u78b0\u5230\u7684\u4eba\u8fd8\u662f\u6bd4\u8f83\u591a\u7684\uff0c\u6240\u4ee5\u5f88\u5bb9\u6613\u5c31\u627e\u5230\u76f8\u5173\u7f51\u9875\uff1a<\/p>\n<p style=\"padding-left: 30px;\">nginx+php-fpm\u51fa\u73b0502 bad gateway\u9519\u8bef\u89e3\u51b3\u65b9\u6cd5 \u2013 \u8fd0\u7ef4\u4e0e\u67b6\u6784 <a href=\"http:\/\/www.nginx.cn\/102.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.nginx.cn\/102.html<\/a><\/p>\n<p style=\"padding-left: 30px;\">Nginx 502 Bad Gateway\u9519\u8bef\u7684\u89e3\u51b3\u529e\u6cd5 &#8211; \u5cf0\u96ea &#8211; \u535a\u5ba2\u56ed <a href=\"http:\/\/www.cnblogs.com\/mybest\/archive\/2012\/12\/27\/2836211.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.cnblogs.com\/mybest\/archive\/2012\/12\/27\/2836211.html<\/a><\/p>\n<p>\u56e0\u4e3a\u6211\u662f\u7528lnmp\u4e00\u952e\u5b89\u88c5\u5305\u8fdb\u884c\u7684\u5b89\u88c5\uff0c\u6240\u4ee5\u6839\u636e\u63d0\u793a\uff0c\u5148\u5230\u5bf9\u5e94\u7684\u8bba\u575b\u4e0a\u53bb\u627e\uff0c\u770b\u770b\u6709\u6ca1\u6709\u4eba\u4e5f\u78b0\u5230\u8fc7\u7c7b\u4f3c\u7684\u60c5\u51b5\uff0c\u627e\u5230\u4e00\u4e2a\uff1a<\/p>\n<hr \/>\n<p>LNMP\u4e00\u952e\u5b89\u88c5\u5305\u7684Nginx 502 Bad Gateway\u9519\u8bef\u53ef\u80fd\u539f\u56e0\u53ca\u89e3\u51b3\u65b9\u6cd5 &#8211; LNMP\u4e00\u952e\u5b89\u88c5\u5305 <a href=\"http:\/\/lnmp.org\/faq\/lnmp-Nginx-502-Bad-Gateway.html\" target=\"_blank\" rel=\"noopener\">http:\/\/lnmp.org\/faq\/lnmp-Nginx-502-Bad-Gateway.html<\/a><\/p>\n<p><strong><span style=\"color: #ff0000;\">\u7b2c\u4e00\u79cd\u539f\u56e0\uff1aLNMP\u6ca1\u6709\u5b89\u88c5\u6210\u529f\uff0c\u811a\u672c\u4e2d\u67d0\u4e9blib\u5305\u53ef\u80fd\u6ca1\u6709\u5b89\u88c5\u4e0a\uff0c\u9020\u6210php\u6ca1\u6709\u7f16\u8bd1\u5b89\u88c5\u6210\u529f\u3002<\/span><\/strong>\u53ef\u4ee5\u770b\u4e00\u4e0b\u662f\u5426\u5b58\u5728\/usr\/local\/php\/sbin\/php-fpm \uff0c\u5982\u679c\u6ca1\u6709\u80af\u5b9a\u6ca1\u5b89\u88c5\u6210\u529f<br \/>\n\u89e3\u51b3\u65b9\u6cd5\uff1a\u53ef\u4ee5\u5c1d\u8bd5\u6839\u636elnmp\u4e00\u952e\u5b89\u88c5\u5305\u4e2d\u7684\u811a\u672c\u624b\u52a8\u5b89\u88c5\u4e00\u4e0b\uff0c\u770b\u770b\u662f\u4ec0\u4e48\u9519\u8bef\u5bfc\u81f4\u7684\uff0c\u5728\u7f51\u4e0a\u641c\u7d22\u4e00\u4e0b\uff0c\u6216\u8005\u628a\u9519\u8bef\u4fe1\u606f\u53d1\u4e0a\u6765\u3002\u5982\u679c\u5b9e\u5728\u4e0d\u4f1a\u63d0\u4f9b\u6309<a href=\"http:\/\/lnmp.org\/install.html\" target=\"_blank\" rel=\"noopener\">http:\/\/lnmp.org\/install.html<\/a>\u8fd9\u4e2a\u5b89\u88c5\u65f6\u7684\u65e5\u5fd7\u6587\u4ef60.9\u7248\u662f\u5728\u5b89\u88c5\u811a\u672c\u6240\u5728\u76ee\u5f55\u6587\u4ef6\u540d\u4e3alnmp.log\uff0c1.0\u662f\u5728\/root\/\u4e0b\u540d\u5b57\u4e3alnmp-install.log\uff08\u53ef\u4ee5\u7528<a href=\"http:\/\/www.vpser.net\/manage\/winscp.html\" target=\"_blank\" rel=\"noopener\">winscp<\/a>\u767b\u9646\u4e0b\u8f7d\u65e5\u5fd7\u6587\u4ef6\uff0c\u538b\u7f29\u5e76\u4e0a\u4f20\u5230\u672c\u8bba\u575b\uff09\uff0c\u6ca1\u6709\u9519\u8bef\u4fe1\u606f\u6211\u4eec\u6ca1\u6cd5\u8bf4\u4ec0\u4e48\u539f\u56e0\u3002\uff08\u9996\u5148\u6392\u9664\u8fd9\u4e00\u70b9\uff0c\u56e0\u4e3a\u6211\u7684\u5b89\u88c5\u662f\u6210\u529f\u7684\uff0c\u800c\u4e14blog\u5df2\u7ecf\u8fd0\u884c\u597d\u4e00\u9635\u4e86\uff0c\u6240\u4ee5\u4e0d\u4f1a\u56e0\u4e3a\u8fd9\u4e00\u70b9\u800c\u5bfc\u81f4502\u9519\u8bef\u3002\uff09<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u7b2c\u4e8c\u79cd\u539f\u56e0<\/strong><\/span>\uff1a<\/p>\n<p>\u5728php.ini\u91cc\uff0ceaccelerator\u914d\u7f6e\u9879\u4e00\u5b9a\u8981\u653e\u5728Zend Optimizer\u914d\u7f6e\u4e4b\u524d\uff0c\u5426\u5219\u4e5f\u53ef\u80fd\u5f15\u8d77502 Bad Gateway\uff08putty\u8fde\u4e0a\u53bb\u4e4b\u540e\u68c0\u67e5\u4e86\uff0c\u4e0d\u662f\u56e0\u4e3a\u8fd9\u4e2a\u95ee\u9898\u3002\uff09<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u7b2c\u4e09\u79cd\u539f\u56e0<\/strong><\/span>\uff1a<br \/>\n\u5728\u5b89\u88c5\u597d\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u51fa\u73b0502\u95ee\u9898\uff0c\u4e00\u822c\u662f\u56e0\u4e3a\u9ed8\u8ba4php-cgi\u8fdb\u7a0b\u662f5\u4e2a\uff0c\u53ef\u80fd\u56e0\u4e3aphpcgi\u8fdb\u7a0b\u4e0d\u591f\u7528\u800c\u9020\u6210502\uff0c\u9700\u8981\u4fee\u6539\/usr\/local\/php\/etc\/php-fpm.conf \u5c06\u5176\u4e2d\u7684max_children\u503c\u9002\u5f53\u589e\u52a0\u3002<br \/>\n\u4e5f\u6709\u53ef\u80fd\u662fmax_requests\u503c\u4e0d\u591f\u7528\u3002\uff08\u5148\u7528\u547d\u4ee4\u68c0\u67e5php-cgi\u7684\u8fde\u63a5\u8fdb\u7a0b\u4e2a\u6570\uff0c\u7136\u540e\u68c0\u67e5\u4e86\u6587\u4ef6\u5185\u5bb9\uff0c\u53d1\u73b0\u4e5f\u4e0d\u662f\u8fd9\u4e2a\u539f\u56e0\u5f15\u8d77\u7684\u3002\uff09<\/p>\n<p>\u7b2c\u56db\u79cd\u539f\u56e0\uff1a<br \/>\nphp\u6267\u884c\u8d85\u65f6\uff0c\u4fee\u6539\/usr\/local\/php\/etc\/php.ini \u5c06max_execution_time \u6539\u4e3a300\uff08\u867d\u7136\u91cc\u9762\u7684timeout\u8bbe\u7f6e\u786e\u5b9e\u4e3a300,\u4f46\u6211\u60f3\u5e94\u8be5\u4e0d\u4f1a\u662f\u56e0\u4e3a\u8fd9\u70b9\u5427\uff1f\u5148\u653e\u653e\uff0c\u770b\u770b\u6709\u6ca1\u6709\u522b\u7684\u4ec0\u4e48\u539f\u56e0\u3002\uff09<\/p>\n<p><span style=\"color: #0000ff;\"><strong>\u7b2c\u4e94\u79cd\u539f\u56e0<\/strong><\/span>\uff1a<br \/>\n\u78c1\u76d8\u7a7a\u95f4\u4e0d\u8db3\uff0c\u5982<a href=\"http:\/\/www.vpser.net\/manage\/delete-mysql-mysql-bin-0000-logs.html\" target=\"_blank\" rel=\"noopener\">mysql\u65e5\u5fd7\u5360\u7528\u5927\u91cf\u7a7a\u95f4<\/a>\u6e05\u7406\u4e00\u4e0b\u78c1\u76d8\u4e0a\u7684\u6587\u4ef6\uff0c\u6709\u90e8\u5206\u5269\u4f59\u7a7a\u95f4\uff0c\u91cd\u542f\u5373\u53ef\u6062\u590d\u3002\uff08\u6267\u884c\u547d\u4ee4df -h\u4e00\u4e0b\uff0c\u53d1\u73b0\u6574\u4e2a\u78c1\u76d8\u7684\u7a7a\u95f4\u5df2\u7ecf\u6ca1\u6709\u4e86o(\u256f\u25a1\u2570)o \u600e\u4e48\u80fd\u8fd9\u6837\uff1f\u8fd8\u6709\u8fd9\u79cd\u653b\u51fb\u65b9\u6cd5\u4e48\uff1f\u592a\u9ad8\u7aef\u4e86\u3002\uff09<\/p>\n<p>\u9644\u4e0a\u547d\u4ee4\u7ed3\u679c&amp;\u622a\u56fe\uff1a<\/p>\n<pre class=\"lang:default decode:true \"># df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\n\/dev\/vda1        20G   20G     0 100% \/\r\nnone            4.0K     0  4.0K   0% \/sys\/fs\/cgroup\r\nudev            239M  4.0K  239M   1% \/dev\r\ntmpfs            50M  332K   50M   1% \/run\r\nnone            5.0M     0  5.0M   0% \/run\/lock\r\nnone            248M     0  248M   0% \/run\/shm\r\nnone            100M     0  100M   0% \/run\/user<\/pre>\n<p><a href=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/09\/502_error_reason.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1231\" src=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/09\/502_error_reason-281x300.png\" alt=\"502_error_reason\" width=\"281\" height=\"300\" \/><\/a><\/p>\n<p>\u7b2c\u516d\u79cd\u539f\u56e0\uff1a<br \/>\n\u67e5\u770bphp-cgi\u8fdb\u7a0b\u662f\u5426\u5728\u8fd0\u884c\uff08ps aux | grep php-cgi\uff09<\/p>\n<p>\u7b2c\u4e03\u79cd\u539f\u56e0\uff1a<br \/>\n\u5c06nginx.conf\u91cc\u7684<br \/>\nfastcgi_connect_timeout<br \/>\nfastcgi_send_timeout<br \/>\nfastcgi_read_timeout\u90fd\u8c03\u5927\u4e00\u70b9\u3002<\/p>\n<p>\u7b2c\u516b\u79cd\u53ef\u80fd\u539f\u56e0\uff1a<a href=\"http:\/\/bbs.vpser.net\/thread-1654-1-1.html\" target=\"_blank\" rel=\"noopener\">http:\/\/bbs.vpser.net\/thread-1654-1-1.html<\/a><\/p>\n<p>\u4e5d\u3001\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u5c06unix\u5957\u63a5\u5b57\u6539\u6210tcp\/ip\u7684\uff0c\u4fee\u6539\/usr\/local\/php\/etc\/php-fpm.cnf \u91cc\u8bbe\u7f6e&lt;value name=\u201clisten_address\u201d&gt;\/tmp\/nginx.socket&lt;\/value&gt; \u6539\u6210&lt;value name=\u201clisten_address\u201d&gt;127.0.0.1:9000&lt;\/value&gt; \uff0c\u540c\u65f6\/usr\/local\/nginx\/conf\/nginx.conf \u53ca\u5176\/usr\/local\/nginx\/conf\/vhost\/ \u4e0b\u9762\u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u91cc\u7684fastcgi_pass\u00a0 unix:\/tmp\/php-cgi.sock; \u66ff\u6362\u4e3afastcgi_pass\u00a0 127.0.0.1:9000;\u00a0 \u4e4b\u540e\u91cd\u542f\u8bd5\u8bd5\u3002<\/p>\n<p>\u5341\u3001\u5982\u679c\u865a\u62df\u4e3b\u673a\u7684\u65e5\u5fd7\u6587\u4ef6\u8fc7\u5927\u4e5f\u53ef\u80fd\u4f1a\u9020\u6210502\u95ee\u9898\u3002<br \/>\n\u5efa\u8bae\u5b9a\u671f\u6e05\u7a7a\u4e00\u4e0b\u865a\u62df\u4e3b\u673a\u7684\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<p>\u5341\u4e00\u3001\u6709\u4e9b\u7a0b\u5e8f\u6216\u8005\u7a0b\u5e8f\u7684\u4e3b\u9898\u6709\u6b7b\u5faa\u73af\u6216\u5176\u4ed6\u975e\u5e38\u5360\u7528\u8d44\u6e90\u7684\u4ee3\u7801\u4e5f\u53ef\u80fd\u4f1a\u5f15\u8d77502\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u6682\u65f6\u6ce8\u91ca\u6389\u53ef\u80fd\u7684\u4e3b\u673a\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u91cd\u542f\u770b\u770b\u662f\u5426\u8fd8\u4f1a502\u3002<\/p>\n<p>\u5341\u4e8c\u3001\u5982\u679c\u4ee5\u4e0a\u65b9\u6cd5\u90fd\u8bd5\u8fc7\uff0c\u4f46\u8fd8\u6709\u65f6\u4f1a\u51fa\u73b0502\u9519\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u6dfb\u52a0502\u81ea\u52a8\u91cd\u542f\u811a\u672c\uff1a<a href=\"http:\/\/bbs.vpser.net\/thread-1913-1-1.html\" target=\"_blank\" rel=\"noopener\">http:\/\/bbs.vpser.net\/thread-1913-1-1.html<\/a><\/p>\n<hr \/>\n<p>\u7136\u540e\u67e5\u627eLinux\u7cfb\u7edf\u4e2d\u7684\u5927\u6587\u4ef6\uff0c\u770b\u770b\u7a76\u7adf\u662f\u54ea\u4e9b\u5185\u5bb9\u628a20G\u7684\u7a7a\u95f4\u90fd\u7ed9\u6211\u5360\u6ee1\u4e86\uff1a<\/p>\n<h6>\u65b9\u6cd5\u4e00\uff1a<\/h6>\n<p>\u5207\u6362\u5230\u6839\u76ee\u5f55\u4e0b\uff08cd \/\uff09\uff0c\u6267\u884c\u547d\u4ee4du\uff08du -sk * | sort -nr | head -10\uff09\u67e5\u770b\u6700\u5360\u7a7a\u95f4\u768410\u4e2a\u76ee\u5f55\/\u6587\u4ef6\uff0c\u7136\u540e\u8fdb\u4e00\u6b65\u5b9a\u4f4d\u5373\u53ef\u3002<\/p>\n<h6>\u65b9\u6cd5\u4e8c\uff1a<\/h6>\n<p>\u4f7f\u7528find\u547d\u4ee4\uff08find \/search_dir -type f -size +3G\uff09<\/p>\n<hr \/>\n<h6>\u67e5\u627e\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/h6>\n<pre class=\"lang:default decode:true \"># du -sh * | sort -nr | head -10\r\n552K    info_gather\r\n344K    bak_script\r\n246M    bak_data\r\n118M    tmp_bak\r\n14M     tools\r\n13G     log_backup\r\n8.0K    vhost.sh\r\n8.0K    sent\r\n6.0M    tmp\r\n4.0K    scripts_bak.sh\r\n\r\n# cd log_backup\/\r\n# ll\r\ntotal 13G\r\ndrwxr-xr-x  2 root root 4.0K Sep 12 10:40 .\/\r\ndrwx------ 14 root root 4.0K Sep 12 11:48 ..\/\r\n-rw-r--r--  1 root root  13G Sep 12 12:13 crontab_exec.log\r\n-rw-r--r--  1 root root  57K Sep  2 05:00 crontab_exec.log.old<\/pre>\n<p>\u5b9a\u4f4d\u5230\u4e86crontab_exec.log\u8fd9\u4e2a\u5de8\u5927\u7684\u6587\u4ef6\uff0c\u8279\uff0c\u6628\u665a\u6211\u5c31\u77e5\u9053\u4f1a\u51fa\u4e2a\u95ee\u9898\uff0cdropbox\u88ab\u5c01\u4e86\u4e4b\u540e\uff08\u7279\u522b\u662f\u5728\u6211\u7684VPN\u8fd8\u6ca1\u6709\u642d\u597d\u4e4b\u524d\uff0c\u6211\u4e5f\u4e0d\u653e\u5fc3\u53bb\u7528shadowsocks\u6216\u514d\u8d39\u4ee3\u7406\u3001\u6539DNS\u7b49\u65b9\u6cd5\u7ffb\u5899\uff0c\u7136\u540e\u8f93\u5165\u7528\u6237\u540d\u5bc6\u7801\uff0c\u592a\u5c3c\u739b\u5371\u9669\u4e86\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u7acb\u5fd7\u6210\u4e3a\u9ed1\u5ba2\u5927\u725b\u7684\u6211\u6765\u8bf4\uff0c\u8fd9\u662f\u4e0d\u53ef\u5bb9\u5fcd\u7684\uff0c\u6240\u4ee5\uff0c\u6211\u5c31\u6ca1\u6709\u8fdb\u884c\u4e0b\u4e00\u6b65\u4e86\uff0c\u7136\u540e\u9519\u8bef\u65e5\u5fd7\u6587\u4ef6\u7adf\u7136\u4f1a\u6709\u8fd9\u4e48\u591a\uff01\uff01\uff09<\/p>\n<p>\u7a7a\u95f4\u90fd\u88ab\u5360\u6ee1\u4e86\uff0c\u90fd\u65e0\u6cd5\u7f16\u8f91cron\u6765\u7981\u6b62\u6267\u884c\u8be5\u4efb\u52a1\u4e86\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># crontab -e\r\n\/tmp\/crontab.jXyfcw\/crontab: No space left on device<\/pre>\n<p>\u5220\u9664\u4e4b\uff1a<\/p>\n<pre class=\"lang:default decode:true\">~\/log_backup# rm crontab_exec.log<\/pre>\n<p>\u4f46\u662f\u4e3a\u4ec0\u4e48\u7a7a\u95f4\u5927\u5c0f\u8fd8\u662f\u6ca1\u6709\u53d8\u5462\uff1f<\/p>\n<pre class=\"lang:default decode:true\">~\/log_backup# df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\n\/dev\/vda1        20G   20G     0 100% \/\r\nnone            4.0K     0  4.0K   0% \/sys\/fs\/cgroup\r\nudev            239M  4.0K  239M   1% \/dev\r\ntmpfs            50M  332K   50M   1% \/run\r\nnone            5.0M     0  5.0M   0% \/run\/lock\r\nnone            248M     0  248M   0% \/run\/shm\r\nnone            100M     0  100M   0% \/run\/user\r\n\r\nroot@hostName:~\/log_backup# crontab -e\r\n\/tmp\/crontab.amBycX\/crontab: No space left on device<\/pre>\n<p>\u660e\u660e\u5df2\u7ecf\u5220\u9664\u4e86\u554a\uff1a<\/p>\n<pre class=\"lang:default decode:true\">root@hostName:~\/log_backup# ll\r\ntotal 2.1M\r\ndrwxr-xr-x  2 root root 4.0K Sep 12 14:13 .\/\r\ndrwx------ 14 root root 4.0K Sep 12 11:48 ..\/\r\n-rw-r--r--  1 root root  57K Sep  2 05:00 crontab_exec.log.old<\/pre>\n<p>\u7ee7\u7eed\u641c\u7d22\uff1a<\/p>\n<p><a href=\"http:\/\/www.sogou.com\/web?query=linux+%E6%B8%85%E9%99%A4%E7%A9%BA%E9%97%B4\" target=\"_blank\" rel=\"noopener\">linux \u6e05\u9664\u7a7a\u95f4 &#8211; \u641c\u72d7\u641c\u7d22<\/a><\/p>\n<p>\u627e\u5230\u4e86\u7bc7\u8bf4\u7684\u5f88\u6e05\u695a\u7684\u6587\u7ae0\uff1alinux\u5220\u9664\u6587\u4ef6\u540e\u6ca1\u6709\u91ca\u653e\u7a7a\u95f4 &#8211; \u51b0\u5200(skate) &#8211; \u535a\u5ba2\u9891\u9053 &#8211; CSDN.NET <a href=\"http:\/\/blog.csdn.net\/wyzxg\/article\/details\/4971843\" target=\"_blank\" rel=\"noopener\">http:\/\/blog.csdn.net\/wyzxg\/article\/details\/4971843<\/a><\/p>\n<hr \/>\n<p><strong>\u5728<\/strong><strong>Linux<\/strong><strong>\u7cfb\u7edf\u4e0a<\/strong><strong>\u5220\u9664\u4e86\u6587\u4ef6\u4e4b\u540e\u6ca1\u6709\u91ca\u653e\u7a7a\u95f4<\/strong><\/p>\n<p>\u4eca\u5929\u53d1\u73b0\u4e00\u53f0\u670d\u52a1\u5668\u7684\u7a7a\u95f4\u6ee1\u4e86\uff0c\u4e8e\u662f\u8981\u6e05\u7a7a\u65e0\u7528\u7684\u6587\u4ef6\uff0c\u5f53\u6211\u5220\u9664\u6587\u4ef6\u540e\uff0c\u53d1\u73b0\u53ef\u7528\u7a7a\u95f4\u6ca1\u6709\u53d8\u5316\uff1a<\/p>\n<pre class=\"lang:default decode:true\">root@crazyof:~# df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\n\/dev\/vda1        20G   20G     0 100% \/\r\nnone            4.0K     0  4.0K   0% \/sys\/fs\/cgroup\r\nudev            239M  4.0K  239M   1% \/dev\r\ntmpfs            50M  332K   50M   1% \/run\r\nnone            5.0M     0  5.0M   0% \/run\/lock\r\nnone            248M     0  248M   0% \/run\/shm\r\nnone            100M     0  100M   0% \/run\/user\r\nroot@crazyof:~# pwd\r\n\/root\r\nroot@crazyof:~# du -sh * | sort -nr | head -10\r\n552K    info_gather\r\n344K    bak_script\r\n246M    bak_data\r\n118M    tmp_bak\r\n14M     tools\r\n13G     log_backup\r\n8.0K    vhost.sh\r\n8.0K    sent\r\n6.0M    tmp\r\n4.0K    scripts_bak.sh\r\nroot@crazyof:~# cd log_backup\/\r\nroot@crazyof:~\/log_backup# ll\r\ntotal 13G\r\ndrwxr-xr-x  2 root root 4.0K Sep 12 10:40 .\/\r\ndrwx------ 14 root root 4.0K Sep 12 11:48 ..\/\r\n-rw-r--r--  1 root root  13G Sep 12 12:13 crontab_exec.log\r\n-rw-r--r--  1 root root  57K Sep  2 05:00 crontab_exec.log.old\r\nroot@crazyof:~\/log_backup# crontab -e\r\n\/tmp\/crontab.jXyfcw\/crontab: No space left on device\r\nroot@crazyof:~\/log_backup# rm crontab_exec.log\r\nroot@crazyof:~\/log_backup# df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\n\/dev\/vda1        20G   20G     0 100% \/\r\nnone            4.0K     0  4.0K   0% \/sys\/fs\/cgroup\r\nudev            239M  4.0K  239M   1% \/dev\r\ntmpfs            50M  332K   50M   1% \/run\r\nnone            5.0M     0  5.0M   0% \/run\/lock\r\nnone            248M     0  248M   0% \/run\/shm\r\nnone            100M     0  100M   0% \/run\/user<\/pre>\n<p><strong>\u672a\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u539f\u56e0\uff1a<\/strong><\/p>\n<p>\u5728Linux\u6216\u8005Unix\u7cfb\u7edf\u4e2d\uff0c\u901a\u8fc7rm\u6216\u8005\u6587\u4ef6\u7ba1\u7406\u5668\u5220\u9664\u6587\u4ef6\u5c06\u4f1a\u4ece\u6587\u4ef6\u7cfb\u7edf\u7684\u76ee\u5f55\u7ed3\u6784\u4e0a\u89e3\u9664\u94fe\u63a5(unlink)\u3002\u7136\u800c\u5982\u679c\u6587\u4ef6\u662f\u88ab\u6253\u5f00\u7684\uff08\u6709\u4e00\u4e2a\u8fdb\u7a0b\u6b63\u5728\u4f7f\u7528\uff09\uff0c\u90a3\u4e48\u8fdb\u7a0b\u5c06\u4ecd\u7136\u53ef\u4ee5\u8bfb\u53d6\u8be5\u6587\u4ef6\uff0c\u78c1\u76d8\u7a7a\u95f4\u4e5f\u4e00\u76f4\u88ab\u5360\u7528\u3002\u800c\u6211\u5220\u9664\u7684\u662f\u5907\u4efd\u6570\u636e\u5e93\/\u7f51\u7ad9\u7684\u811a\u672c\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684log\u6587\u4ef6\uff0c\u5728\u5220\u9664\u7684\u65f6\u5019\u6587\u4ef6\u5e94\u8be5\u6b63\u5728\u88abcrontab\u4e2d\u6307\u5b9a\u7684tee\u547d\u4ee4\u5360\u7528\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u9996\u5148\u83b7\u5f97\u4e00\u4e2a\u5df2\u7ecf\u88ab\u5220\u9664\u4f46\u662f\u4ecd\u7136\u88ab\u5e94\u7528\u7a0b\u5e8f\u5360\u7528\u7684\u6587\u4ef6\u5217\u8868\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre class=\"lang:default decode:true \"># lsof | grep deleted\r\nphp-fpm    1173             root    4u      REG      253,1           0    1179951 \/tmp\/ZCUDK0heRV (deleted)\r\nphp-fpm   17823              www    4u      REG      253,1           0    1179951 \/tmp\/ZCUDK0heRV (deleted)\r\nphp-fpm   17824              www    4u      REG      253,1           0    1179951 \/tmp\/ZCUDK0heRV (deleted)\r\nphp-fpm   17825              www    4u      REG      253,1           0    1179951 \/tmp\/ZCUDK0heRV (deleted)\r\ncron      19896             root    5u      REG      253,1  2147483647    1184733 \/tmp\/tmpfdN5k0J (deleted)\r\nsh        19897             root    1u      REG      253,1  2147483647    1184733 \/tmp\/tmpfdN5k0J (deleted)\r\nsh        19897             root    2u      REG      253,1  2147483647    1184733 \/tmp\/tmpfdN5k0J (deleted)\r\ntee       19899             root    1u      REG      253,1  2147483647    1184733 \/tmp\/tmpfdN5k0J (deleted)\r\ntee       19899             root    2u      REG      253,1  2147483647    1184733 \/tmp\/tmpfdN5k0J (deleted)\r\ntee       19899             root    3w      REG      253,1 13797834752     292713 \/root\/log_backup\/crontab_exec.log (deleted)\r\nphp-fpm   22330              www    4u      REG      253,1           0    1179951 \/tmp\/ZCUDK0heRV (deleted)\r\nphp-fpm   26015              www    4u      REG      253,1           0    1179951 \/tmp\/ZCUDK0heRV (deleted)\r\nphp-fpm   27321              www    4u      REG      253,1           0    1179951 \/tmp\/ZCUDK0heRV (deleted)<\/pre>\n<p>\u4ece\u8f93\u51fa\u7ed3\u679c\u53ef\u4ee5\u770b\u5230\u8be5\u6587\u4ef6\u8fd8\u5728\u88abtee\u547d\u4ee4\u4f7f\u7528\uff0c\u672a\u88ab\u91ca\u653e\u7a7a\u95f4\u3002<\/p>\n<p><strong>\u5982\u4f55\u8ba9\u8fdb\u7a0b\u91ca\u653e\u5462\uff1f<\/strong><\/p>\n<p>\u4e00\u79cd\u975e\u5e38\u76f4\u63a5\u7684\u65b9\u6cd5\u5c31\u662fkill\u6389\u76f8\u5e94\u7684\u8fdb\u7a0b\uff0c\u6216\u8005\u505c\u6389\u4f7f\u7528\u8fd9\u4e2a\u6587\u4ef6\u7684\u5e94\u7528\uff0c\u8ba9os\u81ea\u52a8\u56de\u6536\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n<p>\u4e8e\u662f\uff1a<\/p>\n<p># kill -9 19899<\/p>\n<p>\u7136\u540e\uff0c\u4e00\u5207\u5c31OK\u4e86\uff1a<\/p>\n<pre class=\"lang:default decode:true \"># df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\n\/dev\/vda1        20G  6.8G   12G  37% \/\r\nnone            4.0K     0  4.0K   0% \/sys\/fs\/cgroup\r\nudev            239M  4.0K  239M   1% \/dev\r\ntmpfs            50M  332K   50M   1% \/run\r\nnone            5.0M     0  5.0M   0% \/run\/lock\r\nnone            248M     0  248M   0% \/run\/shm\r\nnone            100M     0  100M   0% \/run\/user<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>\u53c2\u8003\u94fe\u63a5\uff1a<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/cn.bing.com\/search?q=Nginx+502+Bad+Gateway\" target=\"_blank\" rel=\"noopener\">Nginx 502 Bad Gateway &#8211; \u5fc5\u5e94<\/a><\/li>\n<li><a href=\"http:\/\/www.nginx.cn\/1689.html\" target=\"_blank\" rel=\"noopener\">nginx 502 bad gateway timeout \u2013 \u8fd0\u7ef4\u4e0e\u67b6\u6784<\/a><\/li>\n<li><a href=\"http:\/\/down.chinaz.com\/server\/201105\/576_1.htm\" target=\"_blank\" rel=\"noopener\">nginx 502 Bad Gateway \u9519\u8bef\u89e3\u51b3\u529e\u6cd5<\/a><\/li>\n<li><a href=\"http:\/\/www.nginx.cn\/102.html\" target=\"_blank\" rel=\"noopener\">nginx+php-fpm\u51fa\u73b0502 bad gateway\u9519\u8bef\u89e3\u51b3\u65b9\u6cd5<\/a><\/li>\n<li><a href=\"http:\/\/www.cnblogs.com\/mybest\/archive\/2012\/12\/27\/2836211.html\" target=\"_blank\" rel=\"noopener\">Nginx 502 Bad Gateway\u9519\u8bef\u7684\u89e3\u51b3\u529e\u6cd5 &#8211; \u5cf0\u96ea<\/a><\/li>\n<li><a href=\"http:\/\/lnmp.org\/faq\/lnmp-Nginx-502-Bad-Gateway.html\" target=\"_blank\" rel=\"noopener\">LNMP\u4e00\u952e\u5b89\u88c5\u5305\u7684Nginx 502 Bad Gateway\u9519\u8bef\u53ef\u80fd\u539f\u56e0\u53ca\u89e3\u51b3\u65b9\u6cd5 &#8211; LNMP\u4e00\u952e\u5b89\u88c5\u5305<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/wyzxg\/article\/details\/4971843\" target=\"_blank\" rel=\"noopener\">linux\u5220\u9664\u6587\u4ef6\u540e\u6ca1\u6709\u91ca\u653e\u7a7a\u95f4 &#8211; \u51b0\u5200(skate)<\/a><\/li>\n<li><a href=\"http:\/\/www.myexception.cn\/linux-unix\/1716094.html\" target=\"_blank\" rel=\"noopener\">linux \u78c1\u76d8\u7a7a\u95f4\u67e5\u770b\u4e4b\u5927\u6587\u4ef6\u67e5\u5bfb &#8211; Linux\/Unix<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>\u5f85\u53c2\u8003\u6587\u6863\uff1a<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/lnmp.org\/faq\/lnmp-software-list.html\" target=\"_blank\" rel=\"noopener\">LNMP\u5b89\u88c5\u4e86\u54ea\u4e9b\u8f6f\u4ef6\uff1f\u5b89\u88c5\u76ee\u5f55\u5728\u54ea\uff1f<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u4e0a\u534811\u70b9\u5de6\u53f3\u7684\u65f6\u5019\u5728\u8bbf\u95ee\u81ea\u5df1\u7684\u7f51\u7ad9\u65f6\u51fa\u73b0\u4e86502 Bad Gateway\u7684\u9519\u8bef\uff0c\u987f\u65f6\u6709\u70b9\u614c\uff08\u4e0d\u4f1a\u88ab\u9ed1\u4e86\u5427 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11],"tags":[330,331,332,75],"class_list":["post-1229","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","tag-du","tag-lnmp","tag-lsof","tag-nginx"],"views":13026,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=1229"}],"version-history":[{"count":2,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1229\/revisions"}],"predecessor-version":[{"id":3920,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1229\/revisions\/3920"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}