[SOLVED] "Timezone database is corrupt"

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

  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)
    root#admin 11:06:16 /var/www # su web5 -s /bin/bash
    bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
    web5@admin:/var/www$ /usr/bin/php /var/www/pub.radioalgerie.dz/web/scripts/maintenance/maintenance.php pub.radioalgerie.dz
    web5@admin:/var/www$ echo $?
    But when it is run from the cron job, here's what the log file says :
    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

    root#admin 15:36:07 /var/www/conf/web5 # tail php.ini
    ; SSL stream context option.
    ; 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.

    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 Staff Member Howtoforge Staff

    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 ..."
    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 Staff Member Howtoforge Staff

    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 Staff Member Howtoforge Staff

    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.
  8. ychaouche

    ychaouche New Member

    Jesse, you've been of such a serious help. Thank you !
    I have copied the /usr/share/zoneinfo directory inside of /var/www/clients/client1/web5/ with rsync --relative (to create parent directories if necessary) and now the timezone error has gone !

    It all seems that the php jail has got some issues, I will try to see what the jail actually copies and what is left behind. Apparently, php modules are missing :

    [email protected]:/web/scripts/maintenance$ php maintenance.php pub.radioalgerie.dz
    Fatal error: Uncaught Error: Call to undefined function mysqli_connect_errno() in /web/lib/pear/MDB2/Driver/mysqli.php:122
    Stack trace:
    #0 /web/lib/pear/MDB2.php(1417): MDB2_Driver_mysqli->errorInfo(-4)
    #1 /web/lib/pear/MDB2/Driver/mysqli.php(399): MDB2_Driver_Common->customRaiseError(-4, NULL, NULL, '[Error message:...', 'connect')
    #2 /web/lib/OA/DB.php(196): MDB2_Driver_mysqli->connect()
    #3 /web/lib/max/Dal/DataObjects/DB_DataObjectCommon.php(981): OA_DB::singleton()
    #4 /web/lib/max/Dal/DataObjects/DB_DataObjectCommon.php(575): DB_DataObjectCommon->_connect()
    #5 /web/lib/OA/Dal.php(69): DB_DataObjectCommon->init()
    #6 /web/lib/OA/Preferences.php(90): OA_Dal::factoryDO('preferences')
    #7 /web/lib/OA/Preferences.php(374): OA_Preferences::loadPreferences(false, false, false, true)
    #8 /web/lib/OX/Maintenance.php(54): OA_Preferences::loadAdminAccountPreferences()
    #9 /web/scripts/maintenance/maintenance.php(49): OX_Maintenance->__construct()
    #10 {main}
      thrown in /web/lib/pear/MDB2/Driver/mysqli.php on line 122
    [email protected]:/web/scripts/maintenance$
  9. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    You bet.
    That directory is included for php in the jk_init.ini I linked to above; probably it would resolve all your current issues would be resolved, including the missing php modules. You'll need to re-run jk_init to add the php section to your jail again (or use jk_updater_ispc to do that).
    Th0m likes this.
  10. ychaouche

    ychaouche New Member

    I will look into the ini file, maybe not copy it completely, just the desired sections : php, php-commons and php7.2 in my case (shipped w/ Ubuntu 18). Thanks again.

    My next step is to learn how to update a jail after changing the corresponding section in the .ini file. -the doc doesn't expressively mention that but I understand from your earlier posts that it would be jk_init-

Share This Page