filemtime

Find files modified within one hour in HP-UX

空扰寡人 提交于 2019-12-04 21:55:49
I'm searching through the manual page for find I can't see a way to run a command which will find all files modified within an hour. I can see only a way to do it for days. Rakshith Guess this should do find / -type f -mmin -60 This will be listing files starting from root and modified since the past 60 mins. the best you can do in HP-UX using the find command is to look for everything that was modified in the last 24 hours. The HP-UX find command only checks modified time in 24-hour increments. This is done by: find / -type f -mtime 1 This will list all of the filed recursively starting in

Comparing dates to check for old files

若如初见. 提交于 2019-12-04 16:06:53
问题 I want to check if a file is older than a certain amount of time (e.g. 2 days). I managed to get the file creation time in such a way: >>> import os.path, time >>> fileCreation = os.path.getctime(filePath) >>> time.ctime(os.path.getctime(filePath)) 'Mon Aug 22 14:20:38 2011' How can I now check if this is older than 2 days? I work under Linux, but a cross platform solution would be better. Cheers! 回答1: now = time.time() twodays_ago = now - 60*60*24*2 # Number of seconds in two days if

Cost of file modification time checks

主宰稳场 提交于 2019-12-03 11:20:34
For a file containing few bytes under Linux, I need only to process when it was changed since the last time it was processed. I check whether the file was changed by calling PHP clearstatcache(); filemtime(); periodically. Since the entire file will always be tiny, would it be a performance improvement to remove the call to filemtime and check for a file change by comparing the contents with the past contents? Or what is the best method for that, in terms of performance. Use filemtime + clearstatcache To enhance @Ben_D's test: <?php $file = 'small_file.html'; $loops = 1000000; // filesize

Comparing dates to check for old files

喜夏-厌秋 提交于 2019-12-03 10:11:05
I want to check if a file is older than a certain amount of time (e.g. 2 days). I managed to get the file creation time in such a way: >>> import os.path, time >>> fileCreation = os.path.getctime(filePath) >>> time.ctime(os.path.getctime(filePath)) 'Mon Aug 22 14:20:38 2011' How can I now check if this is older than 2 days? I work under Linux, but a cross platform solution would be better. Cheers! now = time.time() twodays_ago = now - 60*60*24*2 # Number of seconds in two days if fileCreation < twodays_ago: print "File is more than two days old" Eduardo I know, it is an old question. But I was

filemtime “warning stat failed for”

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 17:08:29
I already read it so many questions and answers about it but I can't still solve my problem... I'm trying to create a function that deletes all the files with "xml" or "xsl" extension that has been created one day ago. But I'm getting this warning on each file I have: Warning: filemtime() [function.filemtime]: stat failed for post_1003463425.xml in /home/u188867248/public_html/ampc/library.php on line 44 All the files of this directory have the same structure name "post_ + randomNum + .xml" (example: post_1003463425.xml or post_1456463425.xsl). So I think it's not an encoded problem (like I

filemtime “warning stat failed for”

落花浮王杯 提交于 2019-11-30 16:27:27
问题 I already read it so many questions and answers about it but I can't still solve my problem... I'm trying to create a function that deletes all the files with "xml" or "xsl" extension that has been created one day ago. But I'm getting this warning on each file I have: Warning: filemtime() [function.filemtime]: stat failed for post_1003463425.xml in /home/u188867248/public_html/ampc/library.php on line 44 All the files of this directory have the same structure name "post_ + randomNum + .xml"

Get filemtime for most recently updated file in folder

人盡茶涼 提交于 2019-11-29 15:19:39
问题 I have a folder with 4 files in it and I'd like to pull the last modified time of the most recent one (which may not always be the same one). Is there a good way to do that? 回答1: Use a DirectoryIterator to find the files and then simply compare their modified times. This oughta do it: $iterator = new DirectoryIterator('path/to/dir'); $mtime = -1; $file; foreach ($iterator as $fileinfo) { if ($fileinfo->isFile()) { if ($fileinfo->getMTime() > $mtime) { $file = $fileinfo->getFilename(); $mtime

Setting/changing the ctime or “Change time” attribute on a file

我的梦境 提交于 2019-11-29 04:32:41
I wish to change the timestamp metadata on files in Java using the java.nio.Files class. I would like to change all 3 Linux/ext4 timestamps (last modified, access, and changed). I am able to change the first two timestamp fields as follows: Files.setLastModifiedTime(pathToMyFile, myCustomTime); Files.setAttribute(pathToMyFile, "basic:lastAccessTime", myCustomTime); However, I am unable modify the last Change: time on the file. Also, it is concerning that there is no change timestamp mentioned in the documentation . The closest available attribute is creationTime , which I tried without any

How to get locale-independent modified time and creation time of a file in batch?

落花浮王杯 提交于 2019-11-28 13:00:30
With batch variable/parameter expansion like %~t1 one can get a timestamp of a file. I would like to set the year of the file to another variable would like to support multiple locales. How can you get a file's datetime, independent of locale and regional settings? No powershell please. I'll post few options 1) First one is with wmic (not available for XP home edition) ( LastModified can be changed with CreationDate or LastAccessed ) @echo off set file_loc=.\temp_file for %%# in ("%file_loc%") do set file_loc=%%~dpfnx# set file_loc=%file_loc:\=\\% for /f "delims=." %%t in ('"WMIC DATAFILE

Order this array by date modified?

社会主义新天地 提交于 2019-11-28 10:10:41
问题 I have a php file that is creating a array of everything in my users directory, the array is then being sent back to a iPhone. The array that my php is creating is ordering them alphabetically, i want it to sort by the date the file was created.. Here is what my php file looks like <?php $username = $_GET['username']; $path = "$username/default/"; $files = glob("{$path}/{*.jpg,*.jpeg,*.png}", GLOB_BRACE); // output to json echo json_encode($files); ?> How would i do this? Thanks :) 回答1: Using