Why does the change time(ctime) of a directory change when creating a new file in it?
According to stat() system call specification:
The stat() function shall update any time-related fields (as described in XBD File Times Update), before writing into the stat structure.
In the corresponding File Times Update document:
Each function or utility in POSIX.1-2017 that reads or writes data (even if the data does not change) or performs an operation to change file status (even if the file status does not change) indicates which of the appropriate timestamps shall be marked for update.
The list of POSIX system calls contains the following calls related to creation of objects inside a directory:
link()
Upon successful completion, link() shall mark for update the last file status change timestamp of the file. Also, the last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for update.
mkdir()
Upon successful completion, mkdir() shall mark for update the last data access, last data modification, and last file status change timestamps of the directory. Also, the last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for update.
mkfifo()
Upon successful completion, mkfifo() shall mark for update the last data access, last data modification, and last file status change timestamps of the file. Also, the last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for update.
mknod()
Upon successful completion, mknod() shall mark for update the last data access, last data modification, and last file status change timestamps of the file. Also, the last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for update.
open()
If O_CREAT is set and the file did not previously exist, upon successful completion, open() shall mark for update the last data access, last data modification, and last file status change timestamps of the file and the last data modification and last file status change timestamps of the parent directory.
symlink()
Upon successful completion, symlink() shall mark for update the last data access, last data modification, and last file status change timestamps of the symbolic link. Also, the last data modification and last file status change timestamps of the directory that contains the new entry shall be marked for update.
Update file, but not alter file modify date. Can it be done?
Get what is the modification Date of your file.
Change your files content and then you can change the modification date by touch
command.For example
touch -m -t 09082000 file
to change the modification time to 8 sep, 20:00.
You can change the modification date to the past too, for 10/15/1998 12:30 the command would be something like this:
touch -m -t 19981015123000 file
Linux Change Modification date of files?
You could cd
to the folder containing the PHP files and:
touch -d '30 August 2013' *.php
Or if it has sub folders with php files - search through them recursively:
find /path/to/your/php/ -exec touch -d '30 August 2013' *.php {} \;
the folder 'php' in the command above would be included.
Edit:
If you ONLY need to find/change EXACTLY files modified on 23 April 2013, you can use the -mtime
parameter in your find command.
-mtime +60
means you are looking for a file modified 60 days ago or more.-mtime -60
means less than 60 days.-mtime 60
If you skip+
or-
it means exactly 60 days.
So modifying the command above like this:
find /path/to/your/php/ -mtime 127 -exec touch -d '30 August 2013' *.php {} \;
Where 127 is the exact amount of days since 23 April (if my quick head calculation is correct). Else you can change the number to the correct amount of days, or use the +
or -
as described above if it doesn't need to be 'that' exact.
You can read more about the find commands -mtime parameter here:
http://www.cyberciti.biz/faq/howto-finding-files-by-date/
(yes I borrowed 3 lines from there)
Related Topics
Conditional Awk Hashmap Match Lookup
How to Use Ptrace(2) to Change Behaviour of Syscalls
Initramfs Built into Custom Linux Kernel Is Not Running
Why Is Git Creating Read-Only (444) Files
Why Does The Linker Modify a -Defsym "Absolute Address"
How to Install Docker 1.9+ in Centos 6.5
Replace Column If Equal to a Specific Value
Sleep in a While Loop Gets Its Own Pid
Exit from Bash Script But Keep The Process Running
Why Do I Get The Information of "Suspended (Tty Input)" When I Run My Script in The Background
Make Bash Differentiate Between Ctrl-<Letter> and Ctrl-Shift-<Letter>
Kubernetes Pods Terminated - Exit Code 137
Copy N Bytes of Data X to File