{"id":276375,"date":"2023-07-02T04:04:21","date_gmt":"2023-07-01T20:04:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/mfzywlycyysc.html"},"modified":"2023-07-02T04:04:21","modified_gmt":"2023-07-01T20:04:21","slug":"mfzywlycyysc","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/mfzywlycyysc.html","title":{"rendered":"\u514d\u8d39\u8d44\u6e90\u7f51-\u5229\u7528c\u8bed\u8a00\u5220\u9664\u76ee\u5f55\u4e0b\u6587\u4ef6"},"content":{"rendered":"
\u514d\u8d39\u8d44\u6e90\u7f51-<\/p>\n
\u501f\u52a9c\u8bed\u8a00\u5220\u6389\u76ee\u5f55\u4e0b\u6587\u4ef6<\/p>\n
\u8fd1\u6765\u8fd9\u6bb5\u65f6\u95f4\u5de5\u4f5c\u5185\u5bb9\u662f\u5173\u4e8eLinux<\/a>\u4e0b\u7684\u7b80\u5355\u6587\u4ef6\u64cd\u4f5c\uff0c\u539f\u5148\u5bf9\u4e8eLinux\u7cfb\u7edf<\/a>\u4e0b\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570\u90fd\u4e0d\u662f\u592a\u719f\u6089linux\uff0c\u7ecf\u8fc7\u6b64\u6b21\u5b9e\u8df5linux find -name \u904d\u5386\u76ee\u5f55<\/strong>\uff0c\u5bf9\u8fd9\u79cd\u51fd\u6570\u4f7f\u7528\u6709\u4e86\u4e00\u5b9a\u7684\u4e86\u89e3<\/p>\n <\/p>\n \u600e\u6837\u521b\u5efa\u6587\u4ef6\uff0c\u8bfb\u5199\u6587\u4ef6linux find -name \u904d\u5386\u76ee\u5f55<\/strong>\uff0c\u8fd9\u79cd\u7b80\u5355\u7684\u6211\u60f3\u4f60\u4eec\u5e94\u5f53\u662f\u6bd4\u8f83\u719f\u6089\u7684\uff0c\u6211\u6240\u4ecb\u7ecd\u7684\u662f\u600e\u6837\u904d\u5386\u67d0\u4e2a\u76ee\u5f55\uff0c\u4f46\u662f\u5220\u6389\u8be5\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6(\u53ef\u4ee5\u6307\u5b9a\u540e\u7f00\u540d)linux\u547d\u4ee4\u5927\u5168\uff0c\u4f46\u662f\u4e5f\u53ef\u4ee5\u6307\u5b9a<\/p>\n \u6587\u4ef6\u7684\u66f4\u6539\u65f6\u95f4\u8303\u56f4(\u591a\u5c11\u5c0f\u65f6\u66fe\u7ecf\u7684\u65e7\u6587\u4ef6\u53ef\u4ee5\u5220\u6389)\uff0c\u4e0b\u8fb9\u5c31\u662f\u7b80\u5355\u7684\u51fd\u6570\u5b9e\u73b0\uff0c\u4ec5\u4f9b\u521d\u5b66\u8005\u53c2\u8003(\u867d\u7136\u6211\u4e5f\u662f\u521d\u5b66\u8005(^o^)\/~)<\/p>\n \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \n#define FILE_MAX_LEN 256\n \nvoid rmv_old_files(const char *path, const char *suf, int hours)\n{\t\n\tchar filename[FILE_MAX_LEN] = {0};\n\tstruct tm *TM;\n\tstruct dirent *dirp;\n\tstruct stat statbuf;\n\tDIR *dp = NULL;\n\ttime_t curr_time;\n\tint nameLen, offset;\n\tchar *chTemp = NULL;\n\t\n\tcurr_time = time((time_t*)NULL);\n\tdp = opendir(path);\n\tif (NULL == dp)\n\t{\n\t\treturn;\n\t}\t\n\twhile((dirp=readdir(dp)) != NULL)\n\t{\n\t\tif (strcmp(dirp->d_name, \".\")==0 || strcmp(dirp->d_name, \"..\")==0)\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\t\tnameLen = strlen(dirp->d_name);\n\t\tchTemp = dirp->d_name;\n\t\tif (*suf != '')\n\t\t{\n\t\t\toffset = nameLen-strlen(suf);\n\t\t\tif (offsetd_name);\n\t\tif (!stat(filename, &statbuf))\n\t\t{\n\t\t\t\/*check the st_mtime of the file, if more than retention_hours ago then delete it*\/\n\t\t\tif (curr_time-statbuf.st_mtime >= hours*3600 && S_ISREG(statbuf.st_mode))\n\t\t\t{\n\t\t\t\tunlink(filename);\n\t\t\t}\n\t\t}\t\t\t\n\t}\n\tclosedir(dp);\n}<\/pre>\n<\/p>\n