rouch acts strange after touching around


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rouch acts strange after touching around
# 1  
Old 07-14-2011
rouch acts strange after touching around

hi there

Strange title? Well yes...it is strange..."touch" is driving me nutts! Trying to set the access / modified date by a bash script. For a certain time everything works well with all files. After point x the code works only for some files, for others it doesn't. After looking for the cause, I saw that it is a permission issue..so I checked on which permission the access time is no longer editable.

For me, that doesn't make sense at all. I'm logged in as root and am owner of the file. I also don't know what cause that problem....after a reboot, everything works well again. Had anybody already the same problem? What could cause this strange behavior?

The command:
Code:
root@owned:/home/foobar# touch -t 201110101212 test

The output:
if it works:
Code:
root@owned:/home/foobar# stat -c "atime: %x  mtime: %y ctime: %z" test
atime: 2011-10-10 12:12:00.000000000 +0200 
mtime: 2011-10-10  12:12:00.000000000 +0200
ctime: 2011-07-13 14:34:04.383508864 +0200

else:
Code:
atime: 2011-07-13 14:30:21.398403162 +0200 
mtime: 2011-10-10 12:12:00.000000000 +0200
ctime: 2011-07-13 14:30:20.386398151 +0200



List of permissions where it work / doesn't work:
Code:
-r-------- 1 root root 5 2011-07-13 14:11 test //ATIME & MTIME
-rw------- 1 root root 5 2011-10-10 12:11 test //ATIME & MTIME
-rwx------ 1 root root 5 2011-10-10 12:12 test //ATIME & MTIME
  
----r----- 1 root root 5 2011-10-10 12:14 test //ATIME & MTIME
----rw---- 1 root root 5 2011-10-10 12:15 test //ATIME & MTIME
----rwx--- 1 root root 5 2011-10-10 12:16 test //ATIME & MTIME
  
-------r-- 1 root root 5 2011-07-13 14:23 test //MTIME
-------rw- 1 root root 5 2011-07-13 14:25 test //MTIME
-------rwx 1 root root 5 2011-07-13 14:25 test //MTIME
  
-r-----r-- 1 root root 5 2011-07-13 14:27 test //MTIME
-rw----rw- 1 root root 5 2011-07-13 14:28 test //MTIME
  
-rw-r----- 1 root root 5 2011-10-10 12:10 test //ATIME & MTIME
-rw-r--r-- 1 root root 5 2011-07-13 14:30 test //ATIME

The influence are the "other" rights. As soon as it is readable for "other", the modified time is no longer editable. Again, this happens only after....well...after point x....

OS/Kernel
Linux owned 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux

best,
/dev/blah

Last edited by blah0; 07-14-2011 at 01:30 PM..
# 2  
Old 07-14-2011
Does touch actually fail, or do the mtimes just not change?
# 3  
Old 07-14-2011
It doesn't fail...except of, that it doesn't change the access time. In my list above, you see what is changed on which permission:

//ATIME & MTIME = Both changed
//MTIME = only mtime changed
# 4  
Old 07-14-2011
atimes can be funny. Many systems don't bother keeping them at all (to reduce the number of useless disk writes) and some don't bother updating them if the time difference is too small.
# 5  
Old 07-14-2011
Yes, but that's still no reason why it doesn't change it on certain permissions....also, it doesn't explain why it change atime & mtime till a certain event happens.

Example:

0) touch works on all permissions for atime & mtime
1)
event x happens
2) touch changes only mtime for files with permission ??6
3) chmod file to ??0
4) touch works for atime & mtime
5) chmod file to ??6
6) touch works only for mtime again
....

this is strange...for me it looks like a bug...doesn't has to be on touch...but a certain event has to force this behaviour.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove commas if touching any letters

I have a csv file that I am trying to edit. I need to remove any comma that is touching a letter. I used this command to find them. grep , moz_places_good.csv | head -n 10 | grep ,I would think I could use some form of this to just delete the commas and not the letter before it. Just not sure... (5 Replies)
Discussion started by: cokedude
5 Replies

2. Shell Programming and Scripting

Sed/awk to delete single lines that aren't touching other lines

Hello, I'm trying to figure out how to use sed or awk to delete single lines in a file. By single, I mean lines that are not touching any other lines (just one line with white space above and below). Example: one two three four five six seven eight I want it to look like: (6 Replies)
Discussion started by: slimjbe
6 Replies

3. UNIX for Dummies Questions & Answers

Touching files?

So, I think this is a really stupid question, but I'd like to see if I am right. If the following commands are entered: umask 000 touch file1 umask111 touch file2 ...nothing should happen...right? The touch operation isn't going to apply any changes from umask to file1 (and same to... (1 Reply)
Discussion started by: Midwest Product
1 Replies

4. UNIX for Dummies Questions & Answers

Changing rights without touching user and group?

Hello, I have a small problem and would be happy if someone could help me to find a solution: A machine ("server") makes backups of different computers ("clients") using rsync. Users and groups are keept, so that it's possible to copy them back to the client if required. The number of groups... (3 Replies)
Discussion started by: tracer
3 Replies

5. Programming

Help with a C program that acts like the make utility

Hi, I'm trying to create a C program that functions like the make utility in UNIX for personal use. My program would read in from a generic makefile and execute whatever is in that makefile but I'm not sure as to where I should start coding. I would appreciate any help. Thanks. (1 Reply)
Discussion started by: kratos.
1 Replies

6. Shell Programming and Scripting

Is there any s/w acts like UNIX?

Hi Frnds, I do not have UNIX OS and I am practicing on shell programming. is there any software that acts like UNIX? just to practice shell programming. Thanks in advance, Rashmy. (6 Replies)
Discussion started by: smr_rashmy
6 Replies

7. Programming

touching a file which contains slash char

i need to create a file which contains (/) character. Any help to do this (1 Reply)
Discussion started by: axes
1 Replies

8. Solaris

Something strange...

Hi all, Thanks for any replies and for reading in advance. We have upgraded one of our database instances to 10g on a Solaris 8 box, anyhow the other day it started trying to ping loads of weird IP addresses that we don't use, since our systems all run on pretty similar IP's. It all behind... (0 Replies)
Discussion started by: B14speedfreak
0 Replies

9. UNIX for Dummies Questions & Answers

strange

Hi All I am doing a locate <file_name> on my Redhat 7 System. I am unable to get the output. All the keep getting is: locate: this is not a vlaid slocate database: /var/lib/locate/slocate.db What des this mean? Is my system compromised? Thanks in advance. KS (13 Replies)
Discussion started by: skotapal
13 Replies
Login or Register to Ask a Question