LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-26-2014, 02:03 AM   #1
slugman
Member
 
Registered: Jun 2010
Location: AZ
Distribution: Slackware
Posts: 106

Rep: Reputation: 1
update time stamp during mount


Is anyone aware if there is a way to update the timestamp (recursively), on a set of directories, during a mount operation?

I remember being able to do this, unfortunately I forgot exactly what that was.

I've tried employing the exec function in find in conjunction w/ touch to resolve this. It worked on everything except the symlinks.

Code:
#!/bin/bash
#
b=$(ls / | egrep -v "dev|proc|sys")
for i in $b; do
cd /$i \
find . -exec touch {} \;; \
done
‪#‎EOF‬
Basically I need to purchase a new battery for my cmos. Until that happens I have to update time in BIOS if I disable power on the surge protector (which I often do as the system in question is an early poweredge, which stil draws power to keep system in a ready state when power is present--eg plugged in).

I remember my previous solution being much simpler; I'm almost certain it was a switch or paremter in mount, however after scoured through the man page several times and still can't find anything of the sort.

Any help is appreciated.
 
Old 09-26-2014, 03:10 AM   #2
slugman
Member
 
Registered: Jun 2010
Location: AZ
Distribution: Slackware
Posts: 106

Original Poster
Rep: Reputation: 1
I am going to give my script another wirl, this time using the -h switch
 
Old 09-26-2014, 01:42 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
The simplest one I know of is:
Code:
find . -name "*" -exec touch {} \;
And then it depends how you invoke that, but my guess is that part is already done, so therefore put that find into a script and run the script once the mount is established.
 
Old 09-27-2014, 02:16 AM   #4
slugman
Member
 
Registered: Jun 2010
Location: AZ
Distribution: Slackware
Posts: 106

Original Poster
Rep: Reputation: 1
the present directory operator (the period), works just as well, you just have to be present in the director for the command to execute. Which is why I add the cd command as the first element in the for loop. Also, It wouldn't work properly unless the && operator was present. I prefer this method as it allows me to exclude the 3 bind directories (proc, dev, and sys).

And the h switch worked, all symlinks were included in the process.

I could've sworn there was a simpler way to do this. Oh well.
 
Old 09-27-2014, 03:09 AM   #5
slugman
Member
 
Registered: Jun 2010
Location: AZ
Distribution: Slackware
Posts: 106

Original Poster
Rep: Reputation: 1
like, is there a way to set the atime, mtime, and ctime values of a file/directory to a specified value?
 
Old 09-29-2014, 06:42 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by slugman View Post
the present directory operator (the period), works just as well, you just have to be present in the director for the command to execute. Which is why I add the cd command as the first element in the for loop. Also, It wouldn't work properly unless the && operator was present. I prefer this method as it allows me to exclude the 3 bind directories (proc, dev, and sys).
Well you can of course put a directory in place of the period as opposed to performing a cd, but sounds like you already realize that.

Quote:
Originally Posted by slugman View Post
I could've sworn there was a simpler way to do this. Oh well.
One line in a script is not very difficult, and your problem is highly specific. Not sure why it's exactly a problem. I get that you're losing your system clock, you either can use NNTP or manually set your time. The file modification times on your disk should not be being altered merely because you don't have a RTC. What you should do is set your clock either via NNTP or the date shell command before you mount. And leave the times for the files on your disk alone; their modification times should stay stable. I run into this also with like a Beagleboard and not having it attached to an internet connection, if I forget to set the system time, it'll be 1/1/1900 and that will cause problems as I play with files, but if I don't alter any files, then there are no problems.

Quote:
Originally Posted by slugman View Post
like, is there a way to set the atime, mtime, and ctime values of a file/directory to a specified value?
touch sets all of a/m/c-time values. Touch also has a -d option to specify the time you wish to use.
 
Old 10-07-2014, 07:25 AM   #7
slugman
Member
 
Registered: Jun 2010
Location: AZ
Distribution: Slackware
Posts: 106

Original Poster
Rep: Reputation: 1
Quote:
What you should do is set your clock either via NNTP or the date shell command before you mount.
That is the thing, before I realized the issue with my cmos battery, upon system boot my system would boot and keep the time specificed in the system clock (hwclock would always go back in time to October 2004).

Honestly, I'm not sure how I could pass a date command to the system before the disks are mounted. I've since configured all of my servers to use ntpd, ideally I would like to have this ran before disks are mounted, although I'm not quite sure how to accomplish this either. I know Slackware uses sysv style sys init scripts, but I don't think I can touch net scripts before disks are mounted. I am not sure about this however--please anyone correct me if I am wrong. I would love to re-learn how to do this.

But basically the -h switch worked. I ran the script before w/o it, and it basically screwed my system up. All the files were current date, but the important ones were in 2004 (like vmlinuz stuff like that). With the -h switch, the entire filesystem was updated.

I've also been keeping the powerswitch on temporarily until I hit the electronics supply and pick up a 3.1v cmos battery.

Last edited by slugman; 10-07-2014 at 07:42 AM.
 
Old 10-07-2014, 07:57 AM   #8
slugman
Member
 
Registered: Jun 2010
Location: AZ
Distribution: Slackware
Posts: 106

Original Poster
Rep: Reputation: 1
Quote:
or the date shell command before you mount.
Sir, you just jogged my memory! That was the simple solution!

The filesystem I used to update was not my root directory, it was a cifs filesystem. This was in a lab environment I used to work at, either how.. Thanks!
 
  


Reply

Tags
find, mount, timestamp, touch



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Time Stamp AnkitDewang Linux - Newbie 10 07-25-2014 10:23 AM
Linux RHEL4 VM - Issue with slow update of time stamp rajaniyer123 Linux - General 1 06-25-2012 11:52 AM
presentation time stamp nesta Programming 1 11-24-2006 01:57 AM
Time stamp Kalyani1 Linux - Software 0 11-07-2005 02:58 PM
Time stamp in Samba is 11 hours behind time stamp in Linux Linh Linux - General 3 09-04-2003 12:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration