Strange, date and touch returning different times.


 
Thread Tools Search this Thread
Operating Systems Linux Strange, date and touch returning different times.
# 1  
Old 04-08-2010
Strange, date and touch returning different times.

Hi guys,

Hope one of you guys can sort this out for me.

I first noticed this when users were uploading files from our website to our server and the time uploaded was +18 hours ahead of the current time. At first I assumed this was an issue with the coding, but didn't think it was likely as we are using moodle, which gets tested thoroughly.

After going through the actual moodle source code and seeing how the timestamp was generated I noticed it used the php function filemtime.

I then shelled into the server and typed out the command date, which returned the correct date. I then did touch test.txt and noticed that the modified date (using ls -l) for test.txt was 18 hours ahead, which lead me to believe that it wasn't anything to do with Moodle but the unix server itself.

The server is running Ubuntu 8.04.

If you need anymore information please let me know.

Thanks.
# 2  
Old 04-08-2010
Timezone, UTC used, NTP ? Who else has root access ? Ubuntu version ?
# 3  
Old 04-08-2010
Hi Sysgate,

Thanks for your reply.

Below are the comments to your questions.

1) Timezone - /usr/share/zoneinfo/Australia/Brisbane

Like I said earlier, using date returns the correct time.

2) This is the output I received typing date then - Fri Apr 9 11:48:52 EST 2010 - UTC is EST. Is that what you were after? (I am no unix guru, I am a software engineer helping a client - not a system administrator)

3) I have read https://help.ubuntu.com/8.04/serverguide/C/NTP.html and not sure how this relates, as the time returned from date is correct, which uses NTP - doesn't it? I will suggest to the client that they add a cron job to run 'ntpdate ntp.ubuntu.com'.

4) Not sure - I was given a support account - which has given me permissions to create new files and browse. Do different users have different time configurations? The www-data user (web browser) is adding +18 hours to the time as well when a file is uploaded.

5) DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.2"

Regards,

Mark.

---------- Post updated at 09:13 PM ---------- Previous update was at 09:06 PM ----------

Also, I should add a quote I found when researching this issue on Linux Tips - Linux, Clocks, and Time - however we are not running Red Hat which is the distro the articles states that is affected - we however did follow the articles suggestion and created a symbolic link.

"..
The time in some applications is wrong

If some applications (such as date) display the correct time, but others don't, and you are running Red Hat Linux 5.0 or 5.1, you most likely have run into a bug caused by a move of the timezone information from /usr/lib/zoneinfo to /usr/share/zoneinfo. The fix is to create a symbolic link from /usr/lib/zoneinfo to /usr/share/zoneinfo: ``ln -s ../share/zoneinfo /usr/lib/zoneinfo''.
.."
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

2. Shell Programming and Scripting

Bourne returning files based on creation date

I'm wanting to write a bourne shell script that takes in two command line arguments - a directory and a file. With this I want to return a list of files within the directory that are older (based on creation date) than the given file, and print the number of files that have not been listed (they... (4 Replies)
Discussion started by: britty4
4 Replies

3. Shell Programming and Scripting

Strange behavior returning incorrect count

On AIX When I Run the commands below I get - cat tt11.ksh #!/bin/ksh ps -eaf |grep tt11.ksh|grep -v grep|wc -l count=`ps -eaf |grep tt11.ksh|grep -v grep|wc -l` echo "value of count is $count" Output (what I expected) ./tt11.ksh 1 value of count is 1 When I Run... (12 Replies)
Discussion started by: st11669
12 Replies

4. Red Hat

Touch - changing date and time

Hi, I am facing a problem with the command - TOUCH on Linux. See the example below: File on Linux: rw-rw-r-- user1 user1 Jan 01 09:00 test.txt The file - test.txt was created by the user - user1. Now, I want to change the date and time, but using other user - user2 The user2... (12 Replies)
Discussion started by: brjohnsmith
12 Replies

5. Shell Programming and Scripting

Touch a file with creation date as 30 min past.

Hi All, I would like to create a file say test.txt. And the requirement is its creation date should be 30 minutes past. For Example : If i am creating a file at 2:00 am means. Creation time should be 01:30 am. likewise if i am creating a file at 5 pm means. Creation date should be... (5 Replies)
Discussion started by: Girish19
5 Replies

6. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

7. Shell Programming and Scripting

how to make a log.txt and add date and time when use ls,touch and find

Hey guy, how to make the log.txt file and record date and time when ls, touch and find command run? Thanks Boly (13 Replies)
Discussion started by: chenboly
13 Replies

8. UNIX for Dummies Questions & Answers

Touch all files and subdirectories (recursive touch)

I have a folder with many subdirectories and i need to set the modified date to today for everything in it. Please help, thanks! I tried something i found online, find . -print0 | xargs -r0 touch but I got the error: xargs: illegal option -- r (5 Replies)
Discussion started by: glev2005
5 Replies

9. AIX

how would you know your server was rebooted 3 times or 5 times

Is there such location or command to know how many times did you reboot your server in that particular day?in AIX. (3 Replies)
Discussion started by: kenshinhimura
3 Replies

10. UNIX for Advanced & Expert Users

Strange "TOUCH" problem

On HPUX 11i, when using touch command to create a file 45mins old, I get the following error message: touch: cannot change times on /tmp/timestamp Any ideas??? cheers Bud (3 Replies)
Discussion started by: budrito
3 Replies
Login or Register to Ask a Question