23,116
社区成员
发帖
与我相关
我的任务
分享
void ClearExpiredLogFiles(char * strFileName)
{
//char* pEnv;
char sCmd[512];
int nYear ;
int nMonth ;
struct tm *nowtime;
time_t longtime;
time(&longtime);
nowtime=localtime(&longtime);
nYear = nowtime->tm_year+1900 ;
nMonth = nowtime->tm_mon+1;
memset(sCmd, 0, sizeof(sCmd));
if(nMonth > 2)
nMonth -= 2;
else
{
nYear --;
nMonth += 10;
}
sprintf(sCmd, "rm %04d%02d??_%s.log 1>/dev/null 2>&1", nYear, nMonth, strFileName);
system (sCmd);
return;
}