"Timezone database is corrupt"

Discussion in 'General' started by ychaouche, Jul 30, 2020.

Tags:
  1. ychaouche

    ychaouche New Member

    Dear community,
    I am struggling to get a particular cron job working as expected.
    When I run it from the command line, I get no errors and the script works fine (echo $? displays 0)
    Code:
    root#admin 11:06:16 /var/www # su web5 -s /bin/bash
    bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
    [email protected]:/var/www$ /usr/bin/php /var/www/pub.radioalgerie.dz/web/scripts/maintenance/maintenance.php pub.radioalgerie.dz
    [email protected]:/var/www$ echo $?
    0
    [email protected]:/var/www$
    But when it is run from the cron job, here's what the log file says :
    Code:
    root#admin 13:14:08 /var/www/clients/client1/web5/private # tail cron.log
    [...]
    Fatal error: date_default_timezone_get(): Timezone database is corrupt - this should *never* happen! in /web/lib/OX/Admin/Timezones.php on line 136
    [...]
    I added the timezone setting in websites > mywebsite > options > custom php.ini settings, and made sure the additionnal settings were added by inspecting the associated file in /var/www/config/web5/php.ini

    Code:
    root#admin 15:36:07 /var/www/conf/web5 # tail php.ini
    ; SSL stream context option.
    ;openssl.capath=
    ; Local Variables:
    ; tab-width: 4
    ; End:
    date.timezone = Africa/Algiers
    ; commentaire pour voir si c'est pris en compte
    ; ligne vide insérée après ceciroot#admin 15:36:08 /var/www/conf/web5 #
    Note : should ispconfig leave empty newlines at EOF alone ?

    Anyway, restarted apache2 via command line (service apache2 restart) but this didn't fix my timezone error.

    Code:
    Fatal error: date_default_timezone_get(): Timezone database is corrupt - this should *never* happen! in /web/lib/OX/Admin/Timezones.php on 
    Any tips at fixing this ?
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    No mention of what Operating System is on that host ...
    If the error says zomezone database is corrupt, I would believe that is the case and reload that database. On my Debian GNU/Linux 9.13 timezone database is in /usr/share/zoneinfo, and comes from package tzinfo. So I would force reinstall of that package to get a new timezone database.
     
  3. Jesse Norell

    Jesse Norell Well-Known Member

    unknown, I'd guess it doesn't matter for php.ini

    you need to restart the php daemon to take effect, not the web server (ISPConfig should do that for you when you change php.ini directives).

    My guess is that you are running a jailed cronjob (a very good idea), but your jailkit setup is bad and doesn't include all the files that are needed.
     
  4. ychaouche

    ychaouche New Member

    "No mention of what Operating System is on that host ..."
    Code:
    root#admin 16:59:24 ~ # lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 18.04.4 LTS
    Release:        18.04
    Codename:       bionic
    root#admin 16:59:35 ~ #
    That wouldn't explain why the same script works when executing it from the command line.

    Could be (maybe ISPconfig set it up ?), but since this host is managed by ISPConfig I would rather not touch the config myself, by fear of breaking how ISPConfig works or expect things to be.

    My next steps are the following :
    - why working as user web5 from command line works ? if jail is setup, is it only setup for cron jobs ?
    - If the jail is setup, where should I look for the timezone data file ?
     
  5. Jesse Norell

    Jesse Norell Well-Known Member

    It'd be great if ISPConfig could manage everything and fix everything, but that would of course be quite a grandiose undertaking - in practice, you have to perform some server administration outside of ISPConfig, particularly if you find a broken setup like this.

    The php cli environment in your base system seems to work.

    That depends what you setup. When installing ISPConfig, did you install jailkit? (eg. run dpkg -l jailkit to see if you have that package installed) If jailkit is installed, you can use it for your shell user logins (a good security measure over logging in directly to the underlying system environment), and for cronjobs (same improvement over running in system environment, though you can also use a url cron job to help with that). Both use for shell users and cronjobs is configurable, so if you did install jailkit, did you set 'Chrooted cron' type in the client's limits (or limit template)?

    Assuming jailkit is installed, it usually needs configured in /etc/jailkit/jk_init.ini and in System > Sever Config > {server} > Jailkit. You might try starting with jk_init.ini from the stable-3.1 branch then run 'jk_init -j
    /var/www/clients/client1/web5/ php' to re-initialize php in the jail.

    The root of the jail would be /var/www/clients/client1/web5/, and the paths mirror where they are copied from the underlying system, so eg. /var/www/clients/client1/web5/etc/localtime should be a symlink to the correct zoneinfo file under /usr/share/zoneinfo/ (and that file must exist at /var/www/clients/client1/web5/usr/share/zoneinfo/....).
     
  6. ychaouche

    ychaouche New Member

    Thanks a ton, Jesse. You seem to have put in on the right tracks. The jail is installed. I spent the day to read documentation about how jails work. My next step is to learn how to remove binaries and associated libs from the jail after copying them with jail_cp (for example, I would like to have strace inside the jail for troubleshooting and remove it when finished). Then check if the the php.ini file is updated inside the jail, as well as the timezone info files (maybe that is missing).
     
  7. Jesse Norell

    Jesse Norell Well-Known Member

    Simply "rm" works to remove them. There is nothing that tracks what files were installed for a given binary, so you could inadvertently remove a shared library which another binary depends on, but that's easy enough to fix. Search for the jk_updater_ispc script and it can do some cleanup on existing jails, but it won't fix the issue of knowing what all libraries/paths need removed for a jk_cp installed binary.

    There's always the wipe-and-reload option, of removing everything under the directories added by jailkit tools (eg. the usr/ var/ dev/ bin/ sbin/ lib/ lib64/ subdirectories under your jail root, *not* the system /usr /var etc.) then reinstalling the jailkit sections/binaries you want to be there. You wouldn't want to kill all of the "etc/" subdir though, it needs some things there for the jail to function, so probably just clean it up manually.

    That is problematic, as /proc is not mounted inside the jail, though you could probably bind mount it there for the duration of your tracing. I don't know if anything else is needed (device files?) You could always attach to the running process as root from a non-jailkit shell.
     

Share This Page