Tag: server

  • On servers timezone and tmux

    A while ago I was fighting with a timezone set on a server because of the daylight saving time kicked in: during the ghost hour I had troubles with finding automated jobs. Moreover, the server was located overseas and depending on when I was checking the remote date and time, I could get a different time delta.

    Then, the quasi-philosophical question about “which timezone should be set for a remote server: my timezone or local timezone to the server?” has began rolling in my mind.

    After some research, I found a piece of technical advice from Yeller. In short, their advice can be summarized with:

    Use UTC
    Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC. Use UTC.

    (no, really check the linked post: it is full of good and agreeable technical points to use UTC).

    After setting the default timezone for all my servers to UTC, there are some tweaks to live happily ever after with UTC.

    First, add your timezone and export it into the TZ variable:

    echo 'export TZ=/usr/share/zoneinfo/Europe/Rome' >> ~/.zshrc

    This brings a notable advantages:

    • without TZ set:

    % date
    Mon Mar 25 20:56:43 2019
    journalctl -f
    [...]
    Mar 25 20:57:51 golf systemd-logind[1154]: Session 980 logged out. Waiting for processes to exit.

    • with TZ set you get every message* localized in the selected timezone:

    % date
    Mon Mar 25 21:57:53 CET 2019
    journalctl -f
    [...]
    Mar 25 21:57:51 golf systemd-logind[1154]: Session 980 logged out. Waiting for processes to exit.

    * = every message from a sane and decently written program that knows about timezones and honors the TZ variable.

    Secondly, I usually have everything running in a tmux session with the time in the tab bar. After changing the server timezone to UTC, tmux was outputting the time in UTC: I wanted to show my local time as well. In order to show localized time, you have to change some parameters:

    • Output the time and the timezone in the tab bar:

    In ~/.tmux.conf:
    set -g status-right '%a %b %d %H:%M %Z'

    • Make sure to send your TZ variable whenever you are using SSH:

    In ~/.ssh/config:
    Host *
    [...]
    SendEnv TZ

    • Make sure that your SSH server automatically accepts the TZ variable:

    In /etc/ssh/sshd_config
    AcceptEnv [...] TZ

    Restart your sshd service and try to login in the remote server. Your tmux tab bar should show the updated time in your localized timezone, while still using UTC as the global timezone for the server.

  • IIS e Office: come risolvere il problema COMException (0x80004005)

    Ultimamente mi è capitato un problema a runtime durante l’utilizzo di un’applicazione .NET che accedeva ad Office (più in particolare a PowerPoint).

    L’applicazione genera, server side, un file PowerPoint. Tuttavia il processo si blocca durante l’invocazione di PowerPoint con un errore poco parlante (“PowerPoint could not open the file“), nonostante il file PowerPoint da utilizzare come base di partenza sia effettivamente presente nella directory indicata nel source code:

    System.Runtime.InteropServices.COMException (0x80004005): PowerPoint could not open the file. at Microsoft.Office.Interop.PowerPoint.Presentations.Open(String FileName, MsoTriState ReadOnly, MsoTriState Untitled, MsoTriState WithWindow) at

    Dopo un po’ di ricerca, per risolvere questo problema si deve creare una directory vuota (provare per credere) in questa posizione, in base al sistema operativo su cui gira IIS:

    Windows 2008 Server x64 - C:\Windows\SysWOW64\config\systemprofile\Desktop
    Windows 2008 Server x86 - C:\Windows\System32\config\systemprofile\Desktop

    Riavviate IIS, e non otterrete più l’errore indicato.

  • Aggiornare Ubuntu da Hardy (8.04) a Intrepid Ibex (8.10) usando la linea di comando

    Ultimamente mi è capitato di dover aggiornare alcuni server da Ubuntu 8.04 (NB: questa versione è una LTS, ovvero Long Time Support che significa pacchetti aggiornati per 3 anni per la versione desktop e fino a 5 per i server) a Ubuntu 8.10 (questa versione non è LTS!).

    Personalmente preferisco prima aggiornare una macchina di test, e, se tutto va bene, migrare tutte anche le altre macchine alla nuova versione. Ma come si può aggiornare Ubuntu usando soltanto l’accesso a linea di comando (tipicamente ssh)?

    È tutto molto semplice:

    1. Installare (se non è già installato) update manager con: sudo apt-get install update-manager-core
    2. Modificate il file /etc/update-manager/release-upgrades cambiando la riga:
    3. Prompt=lts

      con

      Prompt=normal

      (usate vim o il vostro editor preferito)

    4. Salvate il file e lanciate il processo di aggiornamento con sudo do-release-upgrade

    Se tutto va bene, update-manager vi chiederà se volete effettivamente aggiornare e vi darà anche una stima del tempo previsto:

    Calculating the changes

    Do you want to start the upgrade?

    24 packages are going to be removed. 208 new packages are going to be
    installed. 1018 packages are going to be upgraded.

    You have to download a total of 768M. This download will take about 1
    hour 10 minutes with your connection.

    Fetching and installing the upgrade can take several hours. Once the
    download has finished, the process cannot be cancelled.

    Continue [yN]  Details [d]y