Note that there are some explanatory texts on larger screens.

plurals
  1. PODebugging Ruby Script For Changing Timezone Configuration File On Ubuntu
    primarykey
    data
    text
    <pre><code>require 'java' if ARGV.length == 0 puts "Usage: jruby change_timezone.rb America/Toronto" exit end old_zone = File.read("../../../etc/timezone") puts old_zone time1 = Time.now puts "Current Time:"+time1.localtime.to_s new_zone = ARGV[0] open('../../../etc/timezone','w') do |f| f.puts new_zone.to_s f.close end new_zone = File.read("../../../etc/timezone") puts new_zone time2 = Time.now puts "Updated Time:"+time2.localtime.to_s </code></pre> <p>Above is a ruby script I wrote to change the timezone configuration on ubuntu. It does change the configuration file properly, however, the output for the script is Not as expected.</p> <p>Assume the default value for timezone is America/Toronto. Now run the command, jruby change_timezone.rb Asia/Chongqing, then here's the output:</p> <pre><code>America/Toronto Current Time:Thu Jul 07 14:43:23 -0400 2011 Asia/Chongqing Updated Time:Thu Jul 07 14:43:23 -0400 2011 (My Note: +0800 expected!!!) </code></pre> <p>Continue with the command, jruby change_timezone.rb Europe/Amsterdam, end up with the following:</p> <pre><code>Asia/Chongqing Current Time:Fri Jul 08 03:18:25 +0800 2011 (My Note: it actually got updated from last run!!!) Europe/Amsterdam Updated Time:Fri Jul 08 03:18:25 +0800 2011 (My Note: +0200 expected!!!) </code></pre> <p>Go further with, jruby change_timezone.rb Europe/Amsterdam (My Note: in effect repeating the last command), and get the following:</p> <pre><code>Europe/Amsterdam Current Time:Thu Jul 07 21:21:27 +0200 2011 Europe/Amsterdam Updated Time:Thu Jul 07 21:21:27 +0200 2011 </code></pre> <p>Can someone figure out why it didn't work as expected?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload