查詢某個時間點範圍內改動的檔案

2021-09-06 23:17:05 字數 1549 閱讀 4922

常常因為磁碟空間不足的原因,須要刪除舊檔案,因此希望有乙個函式,可以查詢到某個時間點之前的檔案,並刪除之。

用newlisp來實現的話,須要相似這種功能:

(define (location-file-based-on-modified-time dir-path from-seconds to-seconds file-op)

(unless (directory? dir-path)

(throw-error (string dir-path " folder does not exist"))

)(set 'dir-path (make-sure-folder-path-end-of-slash dir-path))

(recursive-access-dir dir-path file-op (list from-seconds to-seconds)))

呼叫**:

;; @[from-seconds, to-seconds)

(define (show-file file-path ext-context)

(set 'm-time ((file-info file-path) 6))

(set 'from (ext-context 0))

(set 'to (ext-context 1))

(unless (and (>= m-time from) (< m-time to))

(if (regex ".txt$" file-path)

(begin

(println "---begin---")

(println file-path)

(println (string "modified time: " (date m-time)))

(println (string "from time: " (date from)))

(println (string "to time: " (date to)))

(delete-file file-path)

(println (sys-error))

(println "---end---")))

))(set 'cur-time (date-value))

(set 'five-hours-ago (- cur-time (* 3600 5)))

;;(println cur-time)

;;(println five-hours-ago)

(catch (file:location-file-based-on-modified-time "/tmp" five-hours-ago cur-time show-file) 'result)

(if result

(println result))

start-time指的是改動時間的開始, end-time指的是改動時間的結束,依照習慣,這是乙個左閉右開區間: [start-time, end-time), 這兩個時間都使用epoch表示。

假設找到,則返回true, 否則返回nil.

mysql條件查詢 查詢在某個範圍內的資料

1.查詢在工資為10000的員工資訊mysql select from t employee id name address salary 5 小明 四川 6978 f 6 小蘭 天津 12000 f 7 張三 廣東 9807 f 9 小華 廣東 12000 f 10 小靜 山東 7980 m 11...

thinkphp根據時間戳查詢時間範圍內的記錄

這是獲取當月月初和月末的時間戳 beginthismonth mktime 0,0,0,date m 1,date y endthismonth mktime 23,59,59,date m date t date y php獲取今日開始時間戳和結束時間戳 begintoday mktime 0,0...

範圍內資料查詢的sql

between and 查詢範圍內的sql select from 表名 where 要查詢的字段 between 範圍的開始 and 範圍的結束 如果你的資料庫儲存的是時間戳的話,想要查詢某一天到某一天的範圍的話,可以使用這個,當然如果你的資料庫儲存的不是時間戳,也可以使用 to days to ...