I was trying to use find with -mtime +1 to find all directories older than 24 hours but having issues getting this done. I understand that using -mtime +n should remove n*24 hours of data but it seems to only find one folder to remove - 2019-07-05.  Why doesn't it also offer the 2019-07-06 folder?  From find man page:  -mtime n File's  data  was  last modified n*24 hours ago.     Example:  [user@craptaindee mysql] find /some/folder/mysql/ -type d -mtime +1 /some/folder/mysql/2019-07-05  [user@craptaindee mysql] find /some/folder/mysql/ -type d  /some/folder/mysql/ /some/folder/mysql/2019-07-07 /some/folder/mysql/2019-07-06 /some/folder/mysql/2019-07-08 /some/folder/mysql/2019-07-05   Here are the timestamps on the folders  drwxr-xr-x 2 root root 4096 Jul  5 23:40 2019-07-05 drwxr-xr-x 2 root root 4096 Jul  6 23:40 2019-07-06 drwxr-xr-x 2 root root 4096 Jul  7 23:40 2019-07-07 drwxr-xr-x 2 root root 4096 Jul  8 13:00 2019-07-08   I was able to complete my task using -mmin but I don't understand why -mtime doesn't act as I would expect from the man page. Also, -ctime doesn't show the other directory either.   EDIT: I completed these tests just before making this post in the early afternoon in the Pacific Timezone at roughly ~13:00 on July 08 2019.
14647
I'm struggling to wrap my mind around why the find interprets file modification times the way it does.  Specifically, I don't understand why the -mtime +1 doesn't show files less than 48 hours old.   As an example test I created three test files with different modified dates:   [root@foobox findtest]# ls -l total 0 -rw-r--r-- 1 root root 0 Sep 25 08:44 foo1 -rw-r--r-- 1 root root 0 Sep 24 08:14 foo2 -rw-r--r-- 1 root root 0 Sep 23 08:14 foo3   I then ran find with the -mtime +1 switch and got the following output:  [root@foobox findtest]# find -mtime +1 ./foo3   I then ran find with the -mmin +1440 and got the following output:   [root@foobox findtest]# find -mmin +1440 ./foo3 ./foo2   As per the man page for find, I understand that this is expected behavior:   -mtime n         File’s  data was last modified n*24 hours ago.  See the comments         for -atime to understand how rounding affects the interpretation         of file modification times.   -atime n        File  was  last  accessed n*24 hours ago.  When find figures out        how many 24-hour periods ago the file  was  last  accessed,  any        fractional part is ignored, so to match -atime +1, a file has to        have been accessed at least two days ago.   This still doesn't make sense to me though.  So if a file is 1 day, 23 hours, 59 minutes, and 59 seconds old, find -mtime +1 ignores all that and just treats it like it's 1 day, 0 hours, 0 minutes, and 0 seconds old?  In which case, it's not technically older that 1 day and ignored?   Does... not... compute.
31213
I am looking for a way to delete all files older than 7 days in a batch file.  I've searched around the web, and found some examples with hundreds of lines of code, and others that required installing extra command line utilities to accomplish the task.  Similar things can be  in just a couple lines of code. It seems that something at least remotely easy could be done for batch files in Windows. I'm looking for a solution that works in a standard Windows command prompt, without any extra utilities. Please no PowerShell or Cygwin either.
49490
I have a tab delimited file where each record has a timestamp field in 12-hour format:     mm/dd/yyyy hh:mm:ss [AM|PM].   I need to quickly convert these fields to 24-hour time:     mm/dd/yyyy HH:mm:ss.   What would be the best way to do this? I'm running on a Windows platform, but I have access to sed, awk, perl, python, and tcl in addition to the usual Windows tools.
30270
I used to always have the Recent Places shortcut folder sorted by date modified (which is the only reasonable way to sort it). But some time ago it started sorting it by name automatically. No matter what I try it seems that I can never get it to remember to sort by date. Even if I click the Date Modified column header, then navigate to another folder and then come back it is sorted by name again! No other folder behaves like this. Do other people have this problem? Any way to fix it?
24104
I'm using the find command on a Mac to search for a folder called test1. Now test1 folder could be present in the .Trash folder also. How do I exclude the .Trash folder from getting reported in search results or basically any folder I wish to exclude?  $ find $HOME  -name test1 -type d /Users/theuser/.Trash/test1 /Users/theuser/test1  /Users/theuser/Downloads/test1    I want the result to be just  /Users/theuser/test1 /Users/theuser/Downloads/test1    I used grep:  find $HOME  -name test1 -type d | grep -v '.Trash'    to filter out the .Trash result, but I'm interested in knowing if using find alone achieves the same results.
109174
I was writing a query on SEDE, when I noticed there was no "Days Visited" value.    I have circled the available user metrics, alas there is no Days Visited  While there is a CreationDate, this can't be used as accuretly in queries as me (and other people) create accounts on sites but then rarely visit the site.  I'd use this to weight user "scores" but they are probably a lot more uses for this.
38883
I was following this tutorial:    So far, I installed mysql-server mysql-client libmysqlclient-dev, and I was suppose to tell MySQL to create its database directory structure where it will store its information using sudo mysql_install_db.  $ sudo mysql_install_db  [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize [ERROR]   The data directory needs to be specified.   I thought running mysqld --initialize would solve the issue:  $ mysqld --initialize   mysqld: Can't create directory '/var/lib/mysql/' (Errcode: 17 - File exists) [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). [ERROR] Aborting   How do I tell MySQL to create its database directory structure where it will store its information?
103019
I have a folder on my PC in which I keep my temporary files, which I won't be needing after some time. I manually delete them from time to time. What is a way to automate this? I can think of deleting files whose last access time is greater than 20 minutes using Java, but then again, I would have to run it myself which still wouldn't be automation. I using using Windows and file system is NTFS.
88871
Some directories make sense to be sorted by date modified, while others make more sense to be kept sorted alphabetically.   How can I make it so that finder will apply a specified sort by selection on a per-directory basis?   If no such feature exists (In which case I hope somebody at APPL is paying attention), I suppose using/remapping the keyboard shortcuts (Defaults being Cmd+Ctrl+5 for Modified and Cmd+Ctrl+1 for Alphabetical by Name) is the next best thing.
112075
i've got a remote FTP server where i store some backups via cronjob.  The Problem is that i only got a little amount of space so im doing incremental backups. I want to keep the backups about 14 days.  I don't have any other access to the server except FTP and i don't now how to delete files older than x days. Every file got a name with a date in it  yxzNamezxy-date-y-m-d.tar.bz2 (datev-20100111.tar.bz2(   Hope to get some help here.  Cheers and thanks for the hopefully coming answeres,  Dennis  /Edit  I'm trying to use the curl thing which is mantioned in an answere with this part of code  curl ftp://$FTP_SERVER --user $FTP_USER:$FTP_PASS --list-only &gt; files.tmp declare -a aFiles let iCount=0 exec &lt; files.tmp while read sLine do         aFiles[$iCount]=$sLine         ((iCount++)) done  echo -e "\n Files: \n\n\n" echo ${aFiles[@]}  echo -e "\nfor ...\n\n\n" for sFile in $aFiles do         echo -e "\nFile:" $sFile done   but the secound loop doesn't give me more than 1 filename  Cheers,  Dennis
113754
For files within a specific folder, I would like vim to never touch "modified" timestamp at all.  The background is that I use  for blogging, which uses plain text files in ~/bloxsom as source of all articles.  The article date (and therefore order of appearence) is based on modification date of the text file. I don't want article pop up like if it's new whenever I just fix a typo. (I do lots of them... :D)  So far, vim changes timestamp and the original stamp is lost forever.  This is OK and I want to keep it that way for most of files on the system.  But I don't want that for the blog files - I can always touch the file if I need.  Any ideas on how to tweak vim into this behavior?
50479
I am having issues making this syntax work correctly. What I would like to do is remove all tmp and bak files from the specified directory and all subdirectories if the modified date is older than 7 days.  for %G in (.tmp, .bak) do forfiles -p "C:\test\cad projects" -s -m *%G -d -7 -c "cmd /c del @path"   My syntax was gathered from .  If I change my search mask to only include one desired extension then I get correct results.  forfiles -p "c:\test\cad projects" -s -m *.bak -d -7 -c "cmd /c del @path"   I don't do much with batch files so I was hoping someone could assist. Thanks for reading.
104573
Even when /tmp has no file called something, searching for it with find will return 0:    $ find /tmp -name something    $ echo $?   0   How can I get a non-zero exit status when find does not find anything?
110497
CentOS 6.x   I'm confused on when exactly files I place in /tmp/ are deleted.  /etc/cron.daily/tmpwatch has the following:  #! /bin/sh flags=-umc /usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \         -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \         -X '/tmp/hsperfdata_*' 10d /tmp /usr/sbin/tmpwatch "$flags" 30d /var/tmp for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do     if [ -d "$d" ]; then         /usr/sbin/tmpwatch "$flags" -f 30d "$d"     fi done   The section in line 5 that reads -X '/tmp/hsperfdata_*' 10d /tmp leads me to believe that files I place in /tmp/ will remain for 10 days (assuming they aren't locked during deletion of course or the directory is mounted on a tmpfs file system).   Is that correct?
72970
I have this command that I run every 24 hours currently.  find /var/www/html/audio -daystart -maxdepth 1 -mtime +1 -type f -name "*.mp3" -exec rm -f {} \;   I would like to run it every 1 hour and delete files that are older than 1 hour. Is this correct:  find /var/www/html/audio -daystart -maxdepth 1 -mtime **+0.04** -type f -name "*.mp3" -exec rm -f {} \;   I am not sure of my use of the decimal number??  Thanks for any corrections.  EDIT  OR could I just use -mmin 60? Is this correct?  EDIT2  I tried your test, good thing you suggested it. I got an empty result. I want all files OLDER than 60mins to be deleted! How can I do this?? Does my command actually do this?
48101
I want to find some files and then move them.  I can find the file with:  $ find /tmp/ -ctime -1 -name x*   I tried to move them to my ~/play directory with:  $ find /tmp/ -ctime -1 -name x* | xargs mv ~/play/   but that didn't work.  Obviously mv needs two arguments. Not sure if (or how) to reference the xargs 'current item' in the mv command?
77368
Some issues with timezones in PHP have been in the back of my mind for a while now, and I was wondering if there are better ways to handle it than what I'm currently doing.  All of the issues revolve around reformating database stored dates:  When dealing with a site that has to support multiple timezones (for users), to normalize the timezone offest of stored timestamps I always store it with the server timezone using the CURRENT_TIMESTAMP attribute or the NOW() function.   This way I don't have to consider what timezone was set for PHP when the timestamp was entered (since PHP time functions are timezone aware). For each user, according to his preference I set the timezone somewhere in my bootstrap file using:  date_default_timezone_set($timezone);   When I'm looking to format dates with the php date() function, some form of conversion has to take place since MySQL currently stores timestamp in the format Y-m-d H:i:s. With no regard to timezone, you could simply run:  $date = date($format,strtotime($dbTimestamp));   The problem with this is that date() and strtotime() are both timezone aware functions, meaning that if the PHP timezone is set differently from the server timezone, the timezone offset will apply twice (instead of once as we would like).  To deal with this, I usually retrieve MySQL timestamps using the UNIX_TIMESTAMP() function which is not timezone aware, allowing my to apply date() directly on it - thereby applying the timezone offset only once.  I don't really like this 'hack' as I can no longer retrieve those columns as I normally would, or use * to fetch all columns (sometimes it simplifies queries greatly). Also, sometimes it's simply not an option to use UNIX_TIMESTAMP() (especially when using with open-source packages without much abstraction for query composition).  Another issue is when storing the timestamp, when usage of CURRENT_TIMESTAMP or NOW() is not an option - storing a PHP generated timestamp will store it with the timezone offset which I would like to avoid.  I'm probably missing something really basic here, but so far I haven't been able to come up with a generic solution to handle those issues so I'm forced to treat them case-by-case. Your thoughts are very welcome