03-25-2015
Quote:
I see. So you are saying that the function is supposed to work that way.
Only the owner of the file or a superuser can change it.
So in my case it can't be done.
Yes.
Quote:
Is there a setting I can apply to the file to allow all users to access it?
Like a group setting. Or is it hopeless?
Access (read, write, execute) is not the same as
change file characteristics (access permissions, owner ID, group ID, and timestamps).
If a file has access permissions 666 (read and write by owner, group, and world), anybody can set the modification and status change timestamps of the file by writing to it and anybody can set the access timestamp of the file by reading it (but you can only set those timestamps to the current time; not some arbitrary time in the past, the present, or the future as you can with
utime()).
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Does anyone know how to display the time with seconds
of when a file was last modified. I can get hour & minutes but
would also like seconds. --Running AIX (1 Reply)
Discussion started by: edog
1 Replies
2. UNIX for Dummies Questions & Answers
Good morning,
I would like to find all files of a certain type and display their name as well as their modification date.
In order to do this, I would do the following:
find ./ -name *.csv | ????????
My question: what to put after the pipe instead of the question marks? Is there a basic... (5 Replies)
Discussion started by: scampsd
5 Replies
3. UNIX for Dummies Questions & Answers
Hi
I am accessing a file on nfs mounted device, after completing using of the file, i am tring to restore the access time and modification times of the file.
So i got the previous modified time of the file using stat() function and trying to set the date and time for the file, To set these... (6 Replies)
Discussion started by: deepthi.s
6 Replies
4. Shell Programming and Scripting
How can I get and display the last modification time of a file? in scripting or specifically using Batch file
I want this info for me to determine whether an image has been edited or not by using the last modification time and compare it to our stored date of modification.
can somebody help... (5 Replies)
Discussion started by: jaque18
5 Replies
5. Shell Programming and Scripting
Hi All,
I would like to know the file modification time till seconds in Unix. So I tried ls -e and it worked fine. This Solaris 5.10
-rw-rw-r-- 1 test admin 22 Sep 12 11:01:37 2008 test_message
But I am not able to run the same command in SOlaris 5.6 and also in AIX/HP
Is there... (3 Replies)
Discussion started by: rahulkav
3 Replies
6. Shell Programming and Scripting
Hi All,
I have two files (given below) each exists under different paths. I want to compare the modification time stamp of file1.txt is lessthan the modification time of file2.txt.
month1=`ls -l file1.txt | awk '{ print $6}'`
date1=`ls -file1.txt | awk '{ print $7}'`
time1=`ls... (1 Reply)
Discussion started by: Arunprasad
1 Replies
7. UNIX for Dummies Questions & Answers
Hi all,
I need the modification time of a file on a particular day say 3 days before.
I just don't want the last modification time. I need all the modification times on a particualar day.
Is there anyway to do it? Kindly help. Could anyone tell me where the modification time is stored?... (1 Reply)
Discussion started by: vidhyab
1 Replies
8. UNIX for Dummies Questions & Answers
I'm trying to get the date output to be in the form yyyy-mm-dd (e.g. 2013-01-18)
!/bin/sh
modDate=$(stat -c %y $1)
echo $modDate >> $1
When I run this on another file (by typing ./dateScript theFile.txt), I keep getting this message:
stat: illegal option -- c
What's wrong with my code... (2 Replies)
Discussion started by: Nate18
2 Replies
9. Shell Programming and Scripting
Explain it with proper e.g (4 Replies)
Discussion started by: sidpatil
4 Replies
10. Shell Programming and Scripting
SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise
Hi,
In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file.
How do I achieve this?
Regards,
Joe (2 Replies)
Discussion started by: roshanbi
2 Replies
UTIME(2) Linux Programmer's Manual UTIME(2)
NAME
utime, utimes - change file last access and modification times
SYNOPSIS
#include <sys/types.h>
#include <utime.h>
int utime(const char *filename, const struct utimbuf *times);
#include <sys/time.h>
int utimes(const char *filename, const struct timeval times[2]);
DESCRIPTION
The utime() system call changes the access and modification times of the inode specified by filename to the actime and modtime fields of
times respectively.
If times is NULL, then the access and modification times of the file are set to the current time.
Changing timestamps is permitted when: either the process has appropriate privileges, or the effective user ID equals the user ID of the
file, or times is NULL and the process has write permission for the file.
The utimbuf structure is:
struct utimbuf {
time_t actime; /* access time */
time_t modtime; /* modification time */
};
The utime() system call allows specification of timestamps with a resolution of 1 second.
The utimes() system call is similar, but the times argument refers to an array rather than a structure. The elements of this array are
timeval structures, which allow a precision of 1 microsecond for specifying timestamps. The timeval structure is:
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
times[0] specifies the new access time, and times[1] specifies the new modification time. If times is NULL, then analogously to utime(),
the access and modification times of the file are set to the current time.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
ERRORS
EACCES Search permission is denied for one of the directories in the path prefix of path (see also path_resolution(7)).
EACCES times is NULL, the caller's effective user ID does not match the owner of the file, the caller does not have write access to the
file, and the caller is not privileged (Linux: does not have either the CAP_DAC_OVERRIDE or the CAP_FOWNER capability).
ENOENT filename does not exist.
EPERM times is not NULL, the caller's effective UID does not match the owner of the file, and the caller is not privileged (Linux: does
not have the CAP_FOWNER capability).
EROFS path resides on a read-only file system.
CONFORMING TO
utime(): SVr4, POSIX.1-2001. POSIX.1-2008 marks utime() as obsolete.
utimes(): 4.3BSD, POSIX.1-2001.
NOTES
Linux does not allow changing the timestamps on an immutable file, or setting the timestamps to something other than the current time on an
append-only file.
In libc4 and libc5, utimes() is just a wrapper for utime() and hence does not allow a subsecond resolution.
SEE ALSO
chattr(1), futimesat(2), stat(2), utimensat(2), futimes(3), futimens(3)
COLOPHON
This page is part of release 3.25 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/.
Linux 2008-08-06 UTIME(2)