Visit The New, Modern Unix Linux Community

How to change the file modification time of a file on nfs mount point

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to change the file modification time of a file on nfs mount point
# 1  
How to change the file modification time of a file on nfs mount point


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 values for a file on unix system i am converting stat.st_mtime (time_t structure) to struct tm using localtime() and then set the time and date values for the file using setftime().

But i am not able to use the same functions for the nfs mounted files, Please some body help me to write the similar functionality for setting time stamp for nfs files.

Last edited by deepthi.s; 07-04-2008 at 03:35 AM.. Reason: Explained in detail
# 2  
man touch

nfs modification times should not be an issue. Access time updates are sometimes an issue.
# 3  
Can you please explain in detail how to use touch in C code for changing the modification time
# 4  
You don't need to use touch in C code. touch is a command. Just read the man page in order to find out the correct syntax. If you do want to use the touch utility from within the C code you need to use the system() system call.
# 5  
Can we use the touch utility to modify the time stamp of the file on the nfsMounted device, if not tell me any other options that can be used
# 6  
When the touch command is used to change the timestamps of an existing file, it invokes either the old utime() or the new utimes() system call. To change the timestamp on an existing file, you must own the file or be root. Also, you must have write permission on the file or be root. But an NFS mounted file system is controled by the nfs server. It may (and usually does) ignore any root authority from an nfs client. And it may not even be a unix system. It might not even have an real access time for you to modify.
# 7  
Touch is a built in UNIX command.

To call it from within a C program, you have to use "system" function

system ("/usr/bin/touch /path/file-name") ;

Syntax of Touch:
touch [-acm] [-t [[CC]YY]MMDDhhmm[.SS]] file...

Please see the man page for touch for more details.

To answer if you can modify the time stamp on an NFS mounted File: It depends on your access permission. If you are able to write to that file over NFS, yes, you can change the access time.



Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #596
Difficulty: Hard
For loops in C use the familiar syntax of placing the initialization, continuation condition, and interpretation on the same line as the keyword for.
True or False?

10 More Discussions You Might Find Interesting

1. Solaris

Sol 10 - Strange NFS behaviour - adminnfs prefix to mount point

Something has changed..... /etc/vfstab entry:- host1:/backup/RMAN - /RMAN nfs - no rw,hard,rsize=32768,wsize=32768,llockBut when I mount it, and run df -k | grep RMANResults are:- host1:/backup/RMAN 54971960832 26752241664 28219719168 49% ... (1 Reply)
Discussion started by: psychocandy
1 Replies

2. AIX

How to change the mount point of LV?

I have situation where my disk upon reboot, has its mount point as # LOGICAL VOLUME: disk4vol VOLUME GROUP: disk4vg LV IDENTIFIER: 00f609aa00004c0000000152414b786c.1 PERMISSION: read/write VG STATE: active/complete LV STATE: closed/syncd TYPE: jfs2 WRITE VERIFY: off MAX LPs: 512 PP SIZE: 512... (1 Reply)
Discussion started by: mrmurdock
1 Replies

3. Red Hat

Regarding NFS mount point

Dear All, We have two different mount points in Linux NFS one is 15 TB and another one is 15 TB. Can we club both of the two mount points and club in to a single volume in Linux. As we need to restore Database in that single volume. Kindly help us on this. Regards , rj (10 Replies)
Discussion started by: jegaraman
10 Replies

4. Red Hat

NFS mount point

Hi, Can you tell me something about NFS mount point ? Regards, Maddy (3 Replies)
Discussion started by: Maddy123
3 Replies

5. Shell Programming and Scripting

How to change modification time of file?

Explain it with proper e.g (4 Replies)
Discussion started by: sidpatil
4 Replies

6. Shell Programming and Scripting

Script for NFS mount point

Hi , i have create the bash script for nfs but in this script asking for mount point only once it is it prompting for second time. example: do you wants to create any other mount point ? note(if i give yes it should ask me to add the mount point else it should proceed with next step) it... (5 Replies)
Discussion started by: Rahulne25
5 Replies

7. Solaris

No write permission on NFS mount point

hi all i have mounted one nfs mount point but i has no write permission on it. when i am going to make a directory it is giving an error # mkdir 1 mkdir: Failed to make directory "1"; Permission denied i shared using command # share -F nfs -o rw -d "backup" /backup mounted using... (3 Replies)
Discussion started by: nikhil kasar
3 Replies

8. Red Hat

NFS mount point problem

Hi Forum I am trying to mount /NFS as nfs mountpoint on two servers ( A & B ). After mounting the nfs filesystem, both of them behave normally for around 10 mins and after that the NFS file handle become stale and the mountpoints dont respond. While executing df -kh, the output hang out and the... (15 Replies)
Discussion started by: rajdasuwal
15 Replies

9. AIX

NFS mount point monitoring script

Hi, I'm looking to create a NFS mount point monitoring shell script not sure if im going the right way about it so could do with some help. What i was thinking of doing was using the below command but am unsure how to handle the output. So if the filesyetem is active it will return "1" but if... (4 Replies)
Discussion started by: elmesy
4 Replies

10. Linux

one nfs mount point for many logical volumes

hi i am wondering if it is possible to use one nfs mount point for several logical volumes. i have a top level directory /imaging with data1 - data50 below it. each dataX directory is a logical volume configured through LVM. if i mount them separately on the client (i.e. 50 lines in fstab... (1 Reply)
Discussion started by: user23
1 Replies

Featured Tech Videos