Yannick

# 如何删除文件内7天之前的数据？

#1. 用来记住这条信息的时间，

#2. 用来做标记， 以后面好更新数据；

data.timestamp = time((time_t*)NULL); 

time函数解释如下：

NAME
time - get time in seconds

SYNOPSIS
#include <time.h>

time_t time(time_t *t);

DESCRIPTION
time() returns the time as the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).

If t is non-NULL, the return value is also stored in the memory pointed to by t.

RETURN VALUE
On success, the value of time in seconds since the Epoch is returned.  On error, ((time_t) -1) is returned, and errno is set appropriately.

ERRORS

CONFORMING TO
SVr4, 4.3BSD, C89, C99, POSIX.1-2001.  POSIX does not specify any error conditions.

NOTES
POSIX.1  defines  seconds since the Epoch using a formula that approximates the number of seconds between a specified time and the Epoch.  This for‐
mula takes account of the facts that all years that are evenly divisible by 4 are leap years, but years that are evenly divisible  by  100  are  not
leap years unless they are also evenly divisible by 400, in which case they are leap years.  This value is not the same as the actual number of sec‐
onds between the time and the Epoch, because of leap seconds and because system clocks are not required to be synchronized to a standard  reference.
The intention is that the interpretation of seconds since the Epoch values be consistent; see POSIX.1-2008 Rationale A.4.15 for further rationale.

date(1), gettimeofday(2), ctime(3), ftime(3), time(7)

COLOPHON
This  page is part of release 3.54 of the Linux man-pages project.  A description of the project, and information about reporting bugs, can be found
at http://www.kernel.org/doc/man-pages/.


ret =  fprintf(stream, "%hu %u %hhu %u %u %u %hu %u %u %u %hu\n",
data.listNum, data.timestamp, data.type。

	printf("The calendar time is %s\n", <strong>ctime(&timeStamp)</strong>);

                        #define MAX_TIME_DURATION    (60*60*24*6)
tt = time((time_t *)NULL);
if (tt - data.timestamp > MAX_TIME_DURATION) // to add the judgement case. data.timestamp
{
d_printf(D_DEBUG, NULL, "timestamp() - data.timestamp > MAX_TIME_DURATION\n");
}

Best Wishes！

Yannick Tong

#### AIX 删除一天前的文件

2011-12-26 15:36:52

#### linu查找find命令及删除7天前的文件

2017-10-16 16:57:49

#### python 删除指定时间间隔之前的文件

2017-05-23 11:19:24

#### linux定时备份MySQL数据库并删除七天前的备份文件

2015-10-16 17:07:58

#### 脚本删除指定N天前的文件

2015-12-02 19:43:55

#### bat批处理删除指定N天前的文件

2016-02-03 15:15:37

#### 利用PS脚本自动删除7天之前建立的目录-方法1！

2013-10-12 23:00:33

#### Linux中find常见用法示例以及删除7天前的文件

2015-03-05 21:26:41

#### mysql获取7天前数据，日期比较

2010-07-19 10:57:00