PDA

View Full Version : Change server time & Add Unicode



paperweight
09-29-2003, 06:57 AM
Hi,
I need to change the server time to match GMT +8.... how can I do this (via FTP if possible, rather than SSH). Is there a simeple file to edit?

And I am installing a number of apps for Chinese and Japanese and they tell me that my server (VDS) does not have Unicode installed.... how can I add unicode?

Thank you,
pw :?

FZ
09-29-2003, 12:04 PM
pw,

I've also wanted to know how to change the timezone. I think I found the file, etc. that I need to edit, but I never got round to editing it (partly because I don't know how I would change it - syntax-wise - to reflect my GMT+2 timezone).

About your unicode problems, is this a Perl script(s) you're running? If so, you need to find out what the required "module name" is. "Unicode" in itself isn't really that descriptive. Although it may be that these scripts require Perl 5.8 which has Unicode by default (WestHost has 5.6 installed/running). I found a specific module called "Unicode::Japanese", but could not find one for Chinese (not named with the same convention, at least). Have a look at http://search.cpan.org To install a module (I'm assuming you aren't familiar with this), you would have to use SSH (sorry, FTP just doesn't cut it ;)) login and then type cpan after which you would type install Unicode::Japanese and it should do it for you. Again, I am not sure whether this is the correct module you require, but you might as well give it a shot.

If you do figure out the timezone thing, please do let the rest of us know - thanks!

Henning
09-29-2003, 04:22 PM
I also want to know.

I do this in scripts today, but the problem is that westhost change servertime couple off times each year and I don't know what date they do this.
I know the servertime changes in the spring -1 and fall +1 when the US starts and ends Daylight Savings time. But I don't know the date and in what period I should change my scripts to work with the timezone I need.

I don't know if this is normal among hostproviders.

torrin
09-29-2003, 06:44 PM
Here are some links with info on how to do this.

http://www.linuxsa.org.au/tips/time.html
http://www.redhat.com/archives/redhat-install-list/2003-June/msg00381.html

I can't try it because I'm not on 2.0 yet. Somebody try it and let us know if it works.

FZ
09-30-2003, 01:43 PM
Thanks for the links, torrin. Unfortunately, I could not change the time using any of the info there (it won't let me change hardware or system time using date and neither /etc/localtime nor /etc/sysconfig/clock exist). There is a /etc/TIMEZONE symlink to /etc/default/init but editing that did not work either (tried restarting as well as starting a fresh SSH session).

However, after messing around for a while, I finally got it working. This method works in that date shows the correct time (as do the file last modified times when doing an ls -al) After doing the below, I checked Apache logs and it did pick it up on the change successfully.

Here's how to change the time zone on your VDS:
1. You'll have to use SSH. Login...

2. Type (at the command prompt):


export TZ=XXX-Y

and press enter. This requires a little explanation: XXX is the "code" for your time zone - for example GMT (you can even call it anything you like - if you use spaces in the name, make sure to quote the value: "Central European Time-2"). The -Y specifies that the time zone XXX is Y hours ahead (yes, ahead, not behind as the minus would imply) of GMT/UTC (i.e. it is to the east of the Prime Meridian). So, for example, I needed to change mine to Cental African Time (which is GMT plus 2 hours), so I typed export TZ=CAT-2 If your time zone is to the west of the Prime Meridian (i.e. behind GMT or UTC) then you need to replace the - with a + (e.g. export TZ=DEMO+2)

3. Now type date and press enter to make sure that the time is now correct.

4. If you have succeeded in setting the time zone, you need to make your changes permanent. For this, you can either use SSH or FTP (whichever you prefer). You need to open the file .bashrc with a text editor and add this line to it (as above):


export TZ=XXX-Y

Where XXX-Y should, of course, be replaced with what you used above to successfully make the change. Now save the file (and re-upload it if you are using FTP - I think you have to upload it in ASCII mode). Additionally, you should change the TZ value in the /etc/default/init file - not sure what that one does though.

5. See http://www.qnx.com/developer/docs/momentics621_docs/neutrino/lib_ref/global.html for more information, especially if you need it to automatically do daylight savings, etc.

6. Restart (type restart and press enter if using SSH, or restart using the Site Manager) to make sure Apache, etc. pick up on the time zone change.

Also note that though this will change the time zone in relation to file dates and the date/time used in logs, the "last logged in" line you get when you log in to to SSH always shows the system date (I suppose that is what it is supposed to do). Update: it seems that FTP (e.g. a files properties) does not reflect the time zone change, and neither does Procmail. I suppose this change is only effective for "core" log files and for people that use SSH.

Hope that helps.

torrin
09-30-2003, 02:57 PM
4. If you have succeeded in setting the time zone, you need to make your changes permanent. For this, you can either use SSH or FTP (whichever you prefer). You need to open the file .bashrc with a text editor and add this line to it (as above):


export TZ=XXX-Y

Where XXX-Y should, of course, be replaced with what you used above to successfully make the change. Now save the file (and re-upload it if you are using FTP - I think you have to upload it in ASCII mode). Additionally, you should change the TZ value in the /etc/default/init file - not sure what that one does though.

Just for quick clarification .bashrc is the bash user initialization file. It is run everytime you run bash. bash stands for the Bourne Again Shell. It's the shell that gets run everytime you log in using ssh, the console, or telnet. If you look in /etc/passwd you should see it listed on the same line as your username. As for /etc/default/init, I'm not sure about it, but it's probably a system initialization file. It probably gets run everytime the system boots. Again, I'm not on 2.0 yet, so I can't verify any of this, I'm giving you my experience with linux.

FZ
09-30-2003, 03:14 PM
torrin,

Thanks, but I am aware of what the .bashrc does ;) I suggested putting the export line in to it because, and I am sure you know this, in itself export will not retain the changes across (SSH) sessions. I'm by no means an experienced Linux user, so that's the only way I know how to make it non-volatile. I welcome any and all of your input... Maybe you know of a better way to do this - a way that affects Procmail logs and FTP, for example (besides changing the system or hardware clock which it does not let you do)?

torrin
10-01-2003, 07:50 AM
Thanks, but I am aware of what the .bashrc does :wink:

Sorry about that, I didn't realize.


I welcome any and all of your input... Maybe you know of a better way to do this - a way that affects Procmail logs and FTP, for example (besides changing the system or hardware clock which it does not let you do)?

Well, it all depends on what users and shells these programs run under. But let's say they run under bash for the moment. According to the bash man page it says that the system wide initialization file is /etc/profile. So I would start there. Again, I don't have access to 2.0 so I can't try it. So, someone let us know if it works.

FZ
10-01-2003, 12:32 PM
torrin,

Yes, the shell is "GNU bash, version 2.05a.0(1)-release-(i686-pc-linux-gnu)". Unfortunately, /etc/profile doesn't exist either (there is a /etc/profile.d with colours.csh and colours.sh in it). I've read a couple of manpages as well, and almost 99% of the time, the files are either missing or called something else on the WestHost system - I can understand that though.

Anyway, I just wanted to add another update to my post above about changing the time zone: cron is also not affected by the changed time zone. You'll still need to set your cron tasks up according to system time (GMT/UTC minus 6 hours, I think).

torrin
10-01-2003, 02:18 PM
Unfortunately, /etc/profile doesn't exist either

That figures. I don't know if you'll get away with just creating it or not.


(there is a /etc/profile.d with colours.csh and colours.sh in it)

Unfortunately, I don't have a Red Hat box lying around to figure this one out. I do know that Red Hat tends to be the linux that will move all the configuration around from the standard unix places. Anybody using Red Hat linux want to comment?


I've read a couple of manpages as well, and almost 99% of the time, the files are either missing or called something else on the WestHost system - I can understand that though.

Again, that figures. They probably only copy in what they think you need and nothing else. This sound like a good plan until you find that what they think you need and what you need are 2 different things. See scp thread for example.


Anyway, I just wanted to add another update to my post above about changing the time zone: cron is also not affected by the changed time zone. You'll still need to set your cron tasks up according to system time (GMT/UTC minus 6 hours, I think).

I believe cron runs as root. So you'd have to change the .bashrc of the root user which (after reading posts here) you don't have access to. We may be out of luck if just creating /etc/profile doesn't work. Does procmail and the ftp server also run as root. On westhost 1.0 I can't do a ps -ef without getting pemission denied so I don't know.

FZ
10-01-2003, 02:46 PM
Looks like Apache and FTP (as well as mySQL) don't run as root - they run "as" my username. I wasn't able to check how Procmail or cron run, but I am guessing they are also run the same way.

paperweight
10-01-2003, 05:27 PM
hmmm... thanks for all the advice folks. I am trying to follow design64's advice now (and for last couple hours), but it's not budging--can't get time to change. Seems our VDS is configured oddly... Will rest for a while and come back and post any results.

thanks,
pw

paperweight
10-04-2003, 05:27 AM
Uh, Westhost just answered one of my questions sent via the Contact page (this time it only took them a liuttle over 48 hours to get back to me). here's their answer:


I am afraid it's impossible to change your server time. What you'll need to do is use scripts to calculate your current time based on server time. The servers are set to MST, if that helps.


So I guess it's not a VDS, but instead a semi-VDS... :?

FZ
10-04-2003, 07:11 AM
paperweight,

What was going wrong when you were trying my method? Any errors or anything? Surely, if it works for me on my VDS it should work for you. I might point out that it isn't a "complete" solution as the time change does not affect certain things like Cron, Sendmail, Procmail, etc. but at least it affects your SSH sessions and your Apache log (as well as any Perl/PHP scripts you have).

If there is anything unclear in my post above, let me know and I'll try to help you sort it out.

paperweight
10-04-2003, 09:56 PM
Thank you design64. :D

I have a number of different sites on WH now and the time stamp change has been relegated to a lower level of urgency as I need to correct more pressing things at the moment. I will have time in a few days to go through this again and let you all know of any problems I encounter. i hope then, with the ability to concentrate more on your instructions, I'll have success. :wink:

I'll let you know soon...

cheers,
pw

paperweight
10-16-2003, 08:46 PM
Ok, I finally did it. I tried your suggestions.

Howver it doesn't work. it seems to only change the timestamp on telnet and FTP, but the default time used by my programs still go to the server's time, which is in Utah. Hmmm... :<

Anybody have any other solutions?

Dear WH: if you read this, I'm sure this is an issue that very many of your non-Mountain Time customers would like to have fixed... we can fix it on ad hoc basis with individual programs, but this causes lots of work... it is probably much much much easier to give us control over this....

paperweight
10-17-2003, 03:00 AM
Wait! It does work. I made a mistake previously!

It works for MySQL, so if you have programs that grab a date stamp from mysql, this is a beauiful solution.

however it will not work for ftp (i.e. changing stamp on upload/download files) and will not work for things like a PHP file that grabs a timestamp from server.... but for now, this is a start for a good solution. THANK YOU! :> :> :>

FZ
10-17-2003, 04:06 PM
I'm glad it worked (partially). I did notice the same thing - it only seems to affect certain things such as the Apache log, mySQL, etc. But it does also affect the timestamp on files if you use SSH (but not, unfortunately, if you use FTP).