LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 12-10-2009, 03:05 AM   #1
ExWizzard
LQ Newbie
 
Registered: Aug 2009
Posts: 8

Rep: Reputation: 0
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
 
Old 12-10-2009, 03:58 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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' )"
 
Old 12-10-2009, 04:38 AM   #3
ExWizzard
LQ Newbie
 
Registered: Aug 2009
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 12-10-2009, 07:26 AM   #4
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
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
 
Old 12-10-2009, 07:37 AM   #5
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
Quote:
Originally Posted by catkin View Post
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.
 
Old 12-10-2009, 07:49 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by ExWizzard View Post
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
 
Old 12-10-2009, 08:06 AM   #7
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
sometimes I do my best thinking in the shower...

Quote:
Originally Posted by bartonski View Post
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.
 
Old 12-10-2009, 08:15 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by bartonski View Post
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.
 
Old 12-10-2009, 09:23 AM   #9
ExWizzard
LQ Newbie
 
Registered: Aug 2009
Posts: 8

Original Poster
Rep: Reputation: 0
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.
 
Old 12-10-2009, 01:27 PM   #10
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
Quote:
Originally Posted by ExWizzard View Post
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
Code:
echo touch "$fn"
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
Code:
ls -l
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.
 
Old 12-10-2009, 01:56 PM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by ExWizzard View Post
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' )"
 
Old 12-10-2009, 04:10 PM   #12
ExWizzard
LQ Newbie
 
Registered: Aug 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
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.
 
Old 12-11-2009, 02:19 AM   #13
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by ExWizzard View Post
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 View Post
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 View Post
Yes , this gives me the correct set of files]
Glad you got it sorted.
 
Old 12-11-2009, 03:15 AM   #14
ExWizzard
LQ Newbie
 
Registered: Aug 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Yeah thanks for the help all , should be working now.

Last edited by ExWizzard; 12-11-2009 at 11:45 AM.
 
Old 12-11-2009, 11:57 AM   #15
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Slide shows and editing avi files in Ubuntu sladden Linux - Newbie 5 06-11-2009 05:58 AM
How to tell which files have been copied or modified stagnitto Linux - Security 2 10-02-2007 10:51 AM
files modified ? sachin1361 Linux - Enterprise 1 03-13-2007 04:11 AM
gnu make recompiles the source files fully even though the files are not modified yasothamani Linux - Software 4 02-07-2007 07:36 AM
Files modified by switchdesk benjaminrtz Linux - General 1 01-25-2003 11:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration