Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
|
12-10-2009, 03:05 AM
|
#1
|
LQ Newbie
Registered: Aug 2009
Posts: 8
Rep:
|
Ubuntu is creating files that are modified in future
This is a big problem for me , it happens when i torrent stuff and use auto extract from rar. For some certain files it will say that they are modified at 2098-01-01 00:00 which is bad for me.
Im looking for a way to touch those files , is there an equivalent for the find command like "ls -l |grep 2098" ? Or what do you guys suggest , find command fails to find future modified files and i have no idea how to touch them otherwise
|
|
|
12-10-2009, 03:58 AM
|
#2
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Two issues: why is it happening and how to workaround the problem.
Re the first, what is you torrent program?
Re the second (quick and dirty, not tested)
Code:
while read x x x x x x x f8 fn
do
if [[ "$f8" = '2098' ]]; then
echo touch "$fn"
fi
done <<< "$ls -l | grep '2098' )"
|
|
|
12-10-2009, 04:38 AM
|
#3
|
LQ Newbie
Registered: Aug 2009
Posts: 8
Original Poster
Rep:
|
Thanks for the reply , the torrent program is rTorrent 0.8.5/0.12.5
How do i run the script tho? I did save it as script.sh and did ./script.sh but nothing happens
Last edited by ExWizzard; 12-10-2009 at 04:58 AM.
|
|
|
12-10-2009, 07:26 AM
|
#4
|
Senior Member
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,638
Rep:
|
You will need to add "x" to the permissions to allow it to be executed.
From the folder that contains the script file:
chmod +x script.sh
|
|
|
12-10-2009, 07:37 AM
|
#5
|
Member
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Rep:
|
Quote:
Originally Posted by catkin
Two issues: why is it happening and how to workaround the problem.
Re the first, what is you torrent program?
Re the second (quick and dirty, not tested)
Code:
while read x x x x x x x f8 fn
do
if [[ "$f8" = '2098' ]]; then
echo touch "$fn"
fi
done <<< "$ls -l | grep '2098' )"
|
one quick and dirty, not tested, idea deserves another:
Code:
touch -t 209712312359.59 /tmp/foo
find . -newer /tmp/foo | xargs touch
Last edited by bartonski; 12-10-2009 at 07:53 AM.
|
|
|
12-10-2009, 07:49 AM
|
#6
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by ExWizzard
Thanks for the reply , the torrent program is rTorrent 0.8.5/0.12.5
How do i run the script tho? I did save it as script.sh and did ./script.sh but nothing happens
|
On further reflection it is probably not the torrent program that is causing the problem -- it simply downloads the files as uploaded -- but the files themselves or the program used to unrar them.
Oh, sorry I did not realise you are new to running scripts. The full script should be
Code:
#!/bin/bash
while read x x x x x x x f8 fn
do
if [[ "$f8" = '2098' ]]; then # In case some field other than modification time matched 2098
echo touch "$fn" # Remove echo when confident script is finding the right files
fi
done <<< "$ls -l | grep '2098' )"
Then make it executable and run it
Code:
chmod 754 script.sh
./script.sh
|
|
|
12-10-2009, 08:06 AM
|
#7
|
Member
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Rep:
|
sometimes I do my best thinking in the shower...
Quote:
Originally Posted by bartonski
one quick and dirty, not tested, idea deserves another:
Code:
touch -t 209712312359.59 /tmp/foo
find . -newer /tmp/foo | xargs touch
|
This won't work on a 32 bit machine, due to the 2038 bug.
this works:
Code:
$ touch -t 203701010000.00 /tmp/foo; ls -l /tmp/foo
-rw-r--r-- 1 tiger tiger 80 2037-01-01 00:00 /tmp/foo
this doesn't:
Code:
$ touch -t 203901010000.00 /tmp/foo
touch: invalid date format `203901010000.00'
When I first thought about this, my first thought was that if you touch a file beyond the end of the epoch in 2038, the time might wrap around past 0, which would cause horrible problems with my code above (i.e. if you ran it in the root of your file system, you might end up touching a whole bunch of files... that's the kind of thing that makes my stomach tie up in a knot). The author of touch anticipated this, and won't let that happen.
Let that be a lesson to all those who run code by people who say "This is quick and dirty, I haven't tried it yet...". Try it in a sandbox first.
|
|
|
12-10-2009, 08:15 AM
|
#8
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by bartonski
one quick and dirty, not tested, idea deserves another:
Code:
touch -t 209712312359.59 /tmp/foo
find . -newer /tmp/foo | xargs touch
|
MMC
I tried that (actually touch --date <date>) on Slackware 13.0 32-bit and got an error message
Code:
c:~/d/tmp$ touch -t 209712312359.59 foo
touch: invalid date format `209712312359.59'
c:~/d/tmp$ touch -t 200712312359.59 foo
c:~/d/tmp$ ls -l foo
-rw-r--r-- 1 c users 0 Dec 31 2007 foo
Experimenting further it seems the touch command uses signed 32 bit integers to store timestamps thus the last time it can handle (seconds since 1 Jan 1970) is 22:14:07 on 18 Jan 2038. Presumably the inodes on ExWizzard's system can handle later times.
@ExWizzard: what is your distro and which file system type are you using (df -T will show)?
EDIT: did not see bartonski's post before posting this
Last edited by catkin; 12-10-2009 at 01:50 PM.
|
|
|
12-10-2009, 09:23 AM
|
#9
|
LQ Newbie
Registered: Aug 2009
Posts: 8
Original Poster
Rep:
|
im using ext3 and its 64bit ubuntu
I did what you said with the script and when i run it i still dont get any feedback in terminal , did i miss something?
Last edited by ExWizzard; 12-10-2009 at 09:26 AM.
|
|
|
12-10-2009, 01:27 PM
|
#10
|
Member
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Rep:
|
Quote:
Originally Posted by ExWizzard
im using ext3 and its 64bit ubuntu
I did what you said with the script and when i run it i still dont get any feedback in terminal , did i miss something?
|
In catkin's script
Code:
#!/bin/bash
while read x x x x x x x f8 fn
do
if [[ "$f8" = '2098' ]]; then # In case some field other than modification time matched 2098
echo touch "$fn" # Remove echo when confident script is finding the right files
fi
done <<< "$ls -l | grep '2098' )"
If you removed the "echo" in the statement
You shouldn't see anything whatsoever... it will quietly run touch on all of the files that have a date of 2098... theoretically. The echo statement is in there so that you can see which files match, before you go changing any dates.
If you haven't removed the 'echo' statement, and you're still not seeing anything, the run in the directory containing the future file or files, and we can troubleshoot catkin's script.
Alternatively, you can run
Code:
touch -t 209712312359.59 /tmp/foo
find . -newer /tmp/foo -print
This should give you a list of all of the files older than December 31, 2097. If this gives you the correct set of files, you can pipe that through "xargs touch".
Last edited by bartonski; 12-10-2009 at 01:29 PM.
|
|
|
12-10-2009, 01:56 PM
|
#11
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by ExWizzard
im using ext3 and its 64bit ubuntu
I did what you said with the script and when i run it i still dont get any feedback in terminal , did i miss something?
|
Are you, having a 64-bit distro, able to run this command without getting an error message?
Code:
touch -t 209712312359.59 /tmp/foo
Please post your ls -l output as bartonski suggested so we can see why the script didn't work.
BTW, there's a left parenthesis missing in the script (so it should have produced a syntax error ...?)
Code:
done <<< "$( ls -l | grep '2098' )"
|
|
|
12-10-2009, 04:10 PM
|
#12
|
LQ Newbie
Registered: Aug 2009
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by catkin
Are you, having a 64-bit distro, able to run this command without getting an error message?
Code:
touch -t 209712312359.59 /tmp/foo
|
works fine
Quote:
Please post your ls -l output as bartonski suggested so we can see why the script didn't work.
|
ls -l |grep 2098
-rw-r--r-- 1 x admin 781797409 2098-01-01 00:00
x
-rw-r--r-- 1 x admin 1564905860 2098-01-01 00:00
x
-rw-r--r-- 1 x admin 1565044656 2098-01-01 00:00
x
-rw-r--r-- 1 x admin 1565077502 2098-01-01 00:00
x
-rw-r--r-- 1 x admin 781956610 2098-01-01 00:00
x
-rw-r--r-- 1 x admin 1564542665 2098-01-01 00:00
x
-rw-r--r-- 1 x admin 1564853542 2098-01-01 00:00
x
-rw-r--r-- 1 x admin 1564382112 2098-01-01 00:00
x
Quote:
BTW, there's a left parenthesis missing in the script (so it should have produced a syntax error ...?)
Code:
done <<< "$( ls -l | grep '2098' )"
|
Didnt get a error but still same when i added it , and i tried without echo as well , does not work
Quote:
Alternatively, you can run
Code:
touch -t 209712312359.59 /tmp/foo
find . -newer /tmp/foo -print
This should give you a list of all of the files older than December 31, 2097. If this gives you the correct set of files, you can pipe that through "xargs touch".
|
Yes , this gives me the correct set of files]
Last edited by ExWizzard; 12-10-2009 at 04:13 PM.
|
|
|
12-11-2009, 02:19 AM
|
#13
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by ExWizzard
works fine
|
A good reason to migrate to 64-bit -- before 2037! Perhaps the rogue modified time timestamps are caused by the rar files being created on 32-bit systems. If you would like to post the torrent link I'll test on a 32-bit system.
Quote:
Originally Posted by ExWizzard
ls -l |grep 2098
-rw-r--r-- 1 x admin 781797409 2098-01-01 00:00
x
[snip]
|
Ah -- the one time I'm not pedantic about parsing ls output and using the stat command to get file data it backfires on me! The script is not working because the ls -l output fields are different. Here's from Slackware 13.0
Code:
c:~/d$ ls -ld Shell\ Folders/
drwxr-xr-x 7 c 1000 4096 Jun 26 2008 Shell Folders/
Quote:
Originally Posted by ExWizzard
Yes , this gives me the correct set of files]
|
Glad you got it sorted.
|
|
|
12-11-2009, 03:15 AM
|
#14
|
LQ Newbie
Registered: Aug 2009
Posts: 8
Original Poster
Rep:
|
Yeah thanks for the help all , should be working now.
Last edited by ExWizzard; 12-11-2009 at 11:45 AM.
|
|
|
12-11-2009, 11:57 AM
|
#15
|
Member
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Rep:
|
Your find command should work.
In terms of executing this in a cron job, I believe that I would put this in a script. I'm actually going to leave the details to you, because you seem to have a fairly firm grasp on all of the commands involved, and you'll definitely learn more by doing putting all the puzzle pieces together yourself. I forsee a couple of minor gotchas, and I want to see how you handle them. If you end up banging your head against this for more than a couple of hours, post specific questions, and I'll be happy to help.
If you do get it working, please post the results.
|
|
|
All times are GMT -5. The time now is 06:29 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|