Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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
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
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.
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.
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.