Results 1 to 8 of 8

Thread: halt-local.service start during startup

  1. #1
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,307

    Default halt-local.service start during startup

    Hello.

    /etc/init.d/halt-local is call twice : during startup and during shutdown.

    During startup, Here is the beginning of journald :

    Code:
    août 26 11:55:28 linux-7fci systemd[1]: Reached target Sockets.
    août 26 11:55:28 linux-7fci systemd[1]: Reached target Basic System.
    août 26 11:55:28 linux-7fci systemd[1]: Starting Bluetooth service...
    août 26 11:55:28 linux-7fci systemd[1]: Starting /etc/init.d/boot.local Compatibility...
    août 26 11:55:28 linux-7fci systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
    août 26 11:55:28 linux-7fci systemd[1]: Started Self Monitoring and Reporting Technology (SMART) Daemon.
    août 26 11:55:28 linux-7fci avahi-daemon[1209]: Found user 'avahi' (UID 483) and group 'avahi' (GID 482).
    août 26 11:55:28 linux-7fci systemd[1]: Starting Dynamic Kernel Modules System...
    août 26 11:55:28 linux-7fci avahi-daemon[1209]: Successfully dropped root privileges.
    août 26 11:55:28 linux-7fci avahi-daemon[1209]: avahi-daemon 0.6.32 starting up.
    août 26 11:55:28 linux-7fci systemd[1]: Starting Save/Restore Sound Card State...
    août 26 11:55:28 linux-7fci systemd[1]: Starting Machine Check Exception Logging Daemon...
    août 26 11:55:28 linux-7fci systemd[1]: Starting halt.local.service...
    août 26 11:55:28 linux-7fci systemd[1]: Starting Name Service Cache Daemon...
    août 26 11:55:28 linux-7fci systemd[1]: Starting VirtualBox Linux kernel module...
    .....
    .....
    août 26 11:55:28 ASUS-JC-NEW  ETC_INIT-D_HALT-LOCAL[22536]: /backup_sys/000_COMMON/Bin/incron_backup_incron called by /etc/init.d/halt.local - Run @ 2017_08_26__11h55
    .....
    .....
    août 26 11:55:28 linux-7fci systemd[1]: Network Manager is not active.
    août 26 11:55:28 linux-7fci systemd[1]: Dependency failed for Network Manager Wait Online.
    août 26 11:55:28 linux-7fci systemd[1]: NetworkManager-wait-online.service: Job NetworkManager-wait-online.service/start failed with result 'dependency'.
    août 26 11:55:28 linux-7fci systemd[1]: Started Save/Restore Sound Card State.
    août 26 11:55:28 linux-7fci systemd[1]: Started Machine Check Exception Logging Daemon.
    août 26 11:55:28 linux-7fci systemd[1]: Started halt.local.service.
    août 26 11:55:28 linux-7fci systemd[1]: Started Name Service Cache Daemon.
    août 26 11:55:28 linux-7fci kernel: vboxdrv: Found 8 processor cores
    août 26 11:55:28 linux-7fci kernel: vboxdrv: TSC mode is Invariant, tentative frequency 2394550550 Hz
    août 26 11:55:28 linux-7fci kernel: vboxdrv: Successfully loaded version 5.1.26_SUSE (interface 0x002a0000)
    août 26 11:55:28 linux-7fci ModemManager[1303]: <info>  ModemManager (version 1.4.14) starting in system bus...
    août 26 11:55:28 linux-7fci dbus[1247]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='polkit.service'
    
    .....
    .....
    .....

    During shutdown, Here is the end of journald :

    Code:
    .....
    .....
    .....
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped target Multi-User System.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping Self Monitoring and Reporting Technology (SMART) Daemon...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping CUPS Printing Service...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping Command Scheduler...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping Avahi mDNS/DNS-SD Stack...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping irqbalance daemon...
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Stopped target Default.
    août 26 15:48:28 ASUS-JC-NEW bluetoothd[1246]: Stopping SDP server
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Stopped target Basic System.
    août 26 15:48:28 ASUS-JC-NEW bluetoothd[1246]: Exit
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Stopped target Timers.
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Reached target Shutdown.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping halt.local.service...
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Starting Exit the Session...
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Stopped target Sockets.
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Stopped target Paths.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping SuSEfirewall2 phase 2...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping Machine Check Exception Logging Daemon...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping MiniDLNA UPnP-A/V and DLNA media server...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping Modem Manager...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped /etc/init.d/after.local Compatibility.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped target Login Prompts.
    .....
    .....
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopping Save/Restore Sound Card State...
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped Daily Cleanup of Temporary Directories.
    août 26 15:48:28 ASUS-JC-NEW ETC_INIT-D_HALT-LOCAL[22536]: /backup_sys/000_COMMON/Bin/incron_backup_incron called by /etc/init.d/halt.local - Run @ 2017_08_26__15h48
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped target Sound Card.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Unmounted /run/user/1000/gvfs.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped Self Monitoring and Reporting Technology (SMART) Daemon.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped irqbalance daemon.
    .....
    .....
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped Modem Manager.
    août 26 15:48:28 ASUS-JC-NEW systemd[2936]: Received SIGRTMIN+24 from PID 22489 (kill).
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped RealtimeKit Scheduling Policy Service.
    août 26 15:48:28 ASUS-JC-NEW systemd[2998]: Received SIGRTMIN+24 from PID 22466 (kill).
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped Restore /run/initramfs on shutdown.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped halt.local.service.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped Autostart Headless Virtual Box VMs.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped Save/Restore Sound Card State.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped User Manager for UID 481.
    août 26 15:48:28 ASUS-JC-NEW systemd[1]: Stopped User Manager for UID 1000.
    .....
    .....
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Stopped Remount Root and Kernel File Systems.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Removed slice system-systemd\x2dfsck.slice.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Reached target Shutdown.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Starting /etc/init.d/halt.local Compatibility...
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: halt-local.service: Main process exited, code=exited, status=127/n/a
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Failed to start /etc/init.d/halt.local Compatibility. (really print in red)
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: halt-local.service: Unit entered failed state.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: halt-local.service: Failed with result 'exit-code'.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Reached target Final Step.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Starting Power-Off...
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Shutting down.
    août 26 15:48:37 ASUS-JC-NEW systemd-shutdown[1]: Sending SIGTERM to remaining processes...
    août 26 15:48:37 ASUS-JC-NEW haveged[593]: haveged: Stopping due to signal 15
    août 26 15:48:37 ASUS-JC-NEW haveged[593]: haveged starting up
    août 26 15:48:37 ASUS-JC-NEW systemd-journald[398]: Journal stopped
    here is /usr/lib/systemd/system/halt-local.service file

    Code:
    #  This file is part of systemd.
    #
    #  systemd is free software; you can redistribute it and/or modify it
    #  under the terms of the GNU Lesser General Public License as published by
    #  the Free Software Foundation; either version 2.1 of the License, or
    #  (at your option) any later version.
    
    [Unit]
    Description=/etc/init.d/halt.local Compatibility
    ConditionFileIsExecutable=/etc/init.d/halt.local
    DefaultDependencies=no
    After=shutdown.target
    Before=final.target
    
    [Service]
    Type=oneshot
    ExecStart=/etc/init.d/halt.local
    TimeoutSec=0
    StandardOutput=tty
    RemainAfterExit=yes
    here is /etc/init.d/halt.local

    Code:
    #! /bin/sh
    #
    # Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany.  All rights reserved.
    #
    # Author: Werner Fink, 1998
    #         Burchard Steinbild, 1998
    #
    # /etc/init.d/halt.local
    #
    # script with local commands to be executed from init on system shutdown
    #
    # Here you should add things, that should happen directly before shuting
    # down.
    #
    
    /backup_sys/000_COMMON/Bin/incron_backup_incron
    here is /backup_sys/000_COMMON/Bin/incron_backup_incron

    Code:
    #!/bin/bash
    #
    ##################################
    #                                            #
    #    /backup_sys/000_COMMON/Bin/incron_backup_incron
    #                                            #
    #    {2017_08_24}                        #
    #                                            #
    #    ¨version:15-0-a¨                    #
    #                                            #
    ##################################
    #
    # object
    #
    ########################################################
    #
    TIMESTAMP=$(date --date now +%Y_%m_%d__%Hh%M)
    logger -t _ETC_INIT-D_HALT-LOCAL "/backup_sys/000_COMMON/Bin/incron_backup_incron called by /etc/init.d/halt.local - Run @ $TIMESTAMP"
    #
    Any help is welcome
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.2 -- ASUS G731GV KDE leap 15.2 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  2. #2
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,704
    Blog Entries
    1

    Default Re: halt-local.service start during startup

    Have you by chance enabled halt.local explicitly and unintentionally? (which would result in the /etc/init.d/halt.local SysVinit script to be directly to be started at boot).

    Check with
    Code:
    systemctl status halt.local
    Other than that, I would only expect the systemd halt-local.service to take care of the necessary before shutdown.

  3. #3
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,704
    Blog Entries
    1

    Default Re: halt-local.service start during startup

    Focussing on this journal output...
    Code:
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Reached target Shutdown.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Starting /etc/init.d/halt.local Compatibility...
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: halt-local.service: Main process exited, code=exited, status=127/n/a
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: Failed to start /etc/init.d/halt.local Compatibility. (really print in red)
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: halt-local.service: Unit entered failed state.
    août 26 15:48:37 ASUS-JC-NEW systemd[1]: halt-local.service: Failed with result 'exit-code'.
    ...it appears that this fails due to being called too late to do anything useful. (For example it runs after local filesystems have been unmounted.)

    You should consider putting your backup script in the /usr/lib/systemd/system-shutdown/ directory instead.

    Code:
    man systemd-shutdown
    DESCRIPTION
    systemd-halt.service is a system service that is pulled in by halt.target and is responsible for the actual system halt. Similarly, systemd-poweroff.service is pulled in by
    poweroff.target, systemd-reboot.service by reboot.target and systemd-kexec.service by kexec.target to execute the respective actions.

    When these services are run, they ensure that PID 1 is replaced by the /usr/lib/systemd/systemd-shutdown tool which is then responsible for the actual shutdown. Before shutting
    down, this binary will try to unmount all remaining file systems, disable all remaining swap devices, detach all remaining storage devices and kill all remaining processes.

    It is necessary to have this code in a separate binary because otherwise rebooting after an upgrade might be broken — the running PID 1 could still depend on libraries which are
    not available any more, thus keeping the file system busy, which then cannot be re-mounted read-only.

    Immediately before executing the actual system halt/poweroff/reboot/kexec systemd-shutdown will run all executables in /usr/lib/systemd/system-shutdown/ and pass one arguments to
    them: either "halt", "poweroff", "reboot" or "kexec", depending on the chosen action. All executables in this directory are executed in parallel, and execution of the action is
    not continued before all executables finished.

    Note that systemd-halt.service (and the related units) should never be executed directly. Instead, trigger system shutdown with a command such as "systemctl halt" or suchlike.
    Last edited by deano_ferrari; 26-Aug-2017 at 16:07.

  4. #4
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,704
    Blog Entries
    1

    Default Re: halt-local.service start during startup

    Actually, from testing I now see systemd-shutdown runs too late as well.

    Instead, create a custom service (eg /etc/systemd/system/backup.service) that runs earlier...
    Code:
    [Unit]
    Description=backup at shutdown
    Before=shutdown.target reboot.target halt.target
    
    [Service]
    ExecStart=/bin/true
    ExecStop=/path/to/backup-script.sh
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    then enable and start with
    Code:
    systemctl enable backup.service
    Code:
    systemctl start backup.service
    Similar approaches discussed here....
    https://www.reddit.com/r/archlinux/c...ng_scripts_in/
    https://superuser.com/questions/1016...n-with-systemd
    Last edited by deano_ferrari; 27-Aug-2017 at 20:27.

  5. #5
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,307

    Default Re: halt-local.service start during startup

    Quote Originally Posted by deano_ferrari View Post
    Have you by chance enabled halt.local explicitly and unintentionally? (which would result in the /etc/init.d/halt.local SysVinit script to be directly to be started at boot).

    Check with
    Code:
    systemctl status halt.local
    Other than that, I would only expect the systemd halt-local.service to take care of the necessary before shutdown.
    If i remember , yes I have enable explicitly the service by running the command
    Code:
    systemctl enable halt-local.service ;systemctl start halt-local.service ;
    Code:
    ASUS-JC-NEW:~ # systemctl -l status halt.local
    ● halt.local.service
       Loaded: loaded (/etc/init.d/halt.local; bad; vendor preset: disabled)
       Active: active (exited) since Mon 2017-08-28 10:42:54 CEST; 1h 32min ago
         Docs: man:systemd-sysv-generator(8)
        Tasks: 0 (limit: 512)
    
    Aug 28 10:42:31 linux-7fci halt.local[1214]: '/backup_sys/000_COMMON/SBin_SYS/incron-script' -> '/backup_sys/¬001_INSTALL/¬079_INCRON/001_COMPILE_TMP_DIR/INCRON-0.5.12_2017_08_28__10h42/etc/incron-script'
    Aug 28 10:42:31 linux-7fci halt.local[1214]: chown -R user_install:users  /backup_sys/¬001_INSTALL/*
    Aug 28 10:42:45 ASUS-JC-NEW halt.local[1214]: chown -R user_install:users  /backup_sys/¬001_INSTALL/.*
    Aug 28 10:42:54 ASUS-JC-NEW halt.local[1214]: chown -R user_install:users  /backup_sys/000_COMMON/Bin/*
    Aug 28 10:42:54 ASUS-JC-NEW halt.local[1214]: .
    Aug 28 10:42:54 ASUS-JC-NEW halt.local[1214]: .
    Aug 28 10:42:54 ASUS-JC-NEW halt.local[1214]: .
    Aug 28 10:42:54 ASUS-JC-NEW halt.local[1214]: You can close
    Aug 28 10:42:54 ASUS-JC-NEW halt.local[1214]: .
    Aug 28 10:42:54 ASUS-JC-NEW systemd[1]: Started halt.local.service.
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.2 -- ASUS G731GV KDE leap 15.2 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  6. #6
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,704
    Blog Entries
    1

    Default Re: halt-local.service start during startup

    Quote Originally Posted by jcdole View Post
    If i remember , yes I have enable explicitly the service by running the command
    Code:
    systemctl enable halt-local.service ;systemctl start halt-local.service ;
    AFAIU, it is supposed to be called by the systemd halt-local.service rather than being enabled like that. In any case it runs too late to be of value for backup purposes.

  7. #7
    Join Date
    Jun 2008
    Location
    South-West France
    Posts
    1,307

    Default Re: halt-local.service start during startup

    Quote Originally Posted by deano_ferrari View Post
    Actually, from testing I now see systemd-shutdown runs too late as well.

    Instead, create a custom service (eg /etc/systemd/system/backup.service) that runs earlier...
    Code:
    [Unit]
    Description=backup at shutdown
    Before=shutdown.target reboot.target halt.target
    
    [Service]
    ExecStart=/bin/true
    ExecStop=/path/to/backup-script.sh
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    then enable and start with
    Code:
    systemctl enable backup.service
    Code:
    systemctl start backup.service
    Similar approaches discussed here....
    https://www.reddit.com/r/archlinux/c...ng_scripts_in/
    https://superuser.com/questions/1016...n-with-systemd
    Work like a charm.
    Thread is closed

    Thank you very much indeed.
    Thanks for helping. JCD
    __________
    server leap 15.0 -- ASUS g75vw KDE leap 15.2 -- ASUS G731GV KDE leap 15.2 -- acer aspire s13 win 10 home -- HP Omen win 10 home - scan EPSON V500 - Brother HL2250DN - Samsung CLP-325W

  8. #8
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,704
    Blog Entries
    1

    Default Re: halt-local.service start during startup

    Quote Originally Posted by jcdole View Post
    Work like a charm.
    Thread is closed

    Thank you very much indeed.
    You're welcome

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •