|
@@ -281,7 +281,7 @@ int main(int argc, char *argv[]) {
|
|
|
}
|
|
|
int year,month,day,hour,min,sec,i,ty,tm,cnt;
|
|
|
char pwd[70];
|
|
|
- char cmd[512];
|
|
|
+ char cmd[1024];
|
|
|
time_t tt = time(0); //獲取當前時間
|
|
|
struct tm *pst = localtime(&tt); //把time_t類型轉換為struct tm類型
|
|
|
year = pst->tm_year + 1900;
|
|
@@ -290,8 +290,9 @@ int main(int argc, char *argv[]) {
|
|
|
hour = pst->tm_hour;
|
|
|
min = pst->tm_min;
|
|
|
sec = pst->tm_sec;
|
|
|
- sprintf(cmd,"rm -f /mnt/%s-%s-*.zip \n",ModelName,SerialNo);
|
|
|
- system(cmd);
|
|
|
+ // sprintf(cmd,"rm -f /mnt/%s-%s-*.zip \n",ModelName,SerialNo);
|
|
|
+ // system(cmd);
|
|
|
+ system("rm -f /mnt/*.zip");
|
|
|
if((argc == 3) && isdigit(*argv[2])){
|
|
|
cnt=atoi(argv[2]);
|
|
|
}
|
|
@@ -304,6 +305,8 @@ int main(int argc, char *argv[]) {
|
|
|
else{
|
|
|
// strcpy(pwd,"");
|
|
|
}
|
|
|
+ // sprintf(cmd,"zip -9 %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip",pwd,ModelName,SerialNo,year,month,day,hour,min,sec);
|
|
|
+ sprintf(cmd,"zip -9 %s \t /mnt/log.zip",pwd);
|
|
|
for(i=0;i<cnt;i++){
|
|
|
if(month-i<1){
|
|
|
tm=month-i+12;
|
|
@@ -313,25 +316,21 @@ int main(int argc, char *argv[]) {
|
|
|
tm=month-i;
|
|
|
ty=year;
|
|
|
}
|
|
|
- sprintf(cmd,"zip %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/ChargeLog/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
|
|
|
- system(cmd);
|
|
|
- sprintf(cmd,"zip %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/EventLog/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
|
|
|
- system(cmd);
|
|
|
- sprintf(cmd,"zip %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/SystemLog/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
|
|
|
- system(cmd);
|
|
|
- sprintf(cmd,"zip %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/OCPP/*%04d*%02d*\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec,ty,tm);
|
|
|
- system(cmd);
|
|
|
+ sprintf(cmd,"%s \t /Storage/ChargeLog/*%04d*%02d*",cmd,ty,tm);
|
|
|
+ sprintf(cmd,"%s \t /Storage/EventLog/*%04d*%02d*",cmd,ty,tm);
|
|
|
+ sprintf(cmd,"%s \t /Storage/SystemLog/*%04d*%02d*",cmd,ty,tm);
|
|
|
+ sprintf(cmd,"%s \t /Storage/OCPP/*%04d*%02d*",cmd,ty,tm);
|
|
|
}
|
|
|
if(isCCS==0){
|
|
|
- sprintf(cmd,"zip %s \t /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip \t /Storage/CCS*.zip\n",pwd,ModelName,SerialNo,year,month,day,hour,min,sec);
|
|
|
- system(cmd);
|
|
|
+ sprintf(cmd,"%s \t /Storage/CCS*.zip",cmd);
|
|
|
}
|
|
|
+ system(cmd);
|
|
|
if(isCCS==1){
|
|
|
const char* server="192.168.0.10";
|
|
|
const char* username="vern";
|
|
|
const char* password="vern@delta";
|
|
|
//sprintf(cmd,"/usr/bin/ftpput -u %s -p %s %s /Storage/CCS/CCS%d-%04d%02d%02d%02d%02d%02d.zip /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip",username,password,server,CCSID,year,month,day,hour,min,sec,ModelName,SerialNo,year,month,day,hour,min,sec);
|
|
|
- sprintf(cmd,"/usr/bin/ftpput -u %s -p %s %s /Storage/CCS%d.zip /mnt/%s-%s-%04d%02d%02d%02d%02d%02d.zip",username,password,server,CCSID,ModelName,SerialNo,year,month,day,hour,min,sec);
|
|
|
+ sprintf(cmd,"/usr/bin/ftpput -u %s -p %s %s /Storage/CCS%d.zip /mnt/log.zip",username,password,server,CCSID);
|
|
|
system(cmd);
|
|
|
}
|
|
|
printf("Log packing is done!\n");
|