• Cannot enable systemd timer


    Hello everyone,

    I have an issue automatically starting a systemd timer at startup:

    On my laptop I want the NFS shares from my NAS to be automatically mounted when I’m on my local network (when the NAS is reachable) and to be automatically dismounted when I disconnect from my network. I’m using the following guide: https://wiki.archlinux.org/index.php/NFS#Automatic_mount_handling

    • I’ve defined my mount points as noauto in fstab
    • I’ve created a /usr/local/bin/auto_mount_shares script that pings the NAS and mounts/unmnounts the shares
    • I’ve created the /etc/systemd/system/auto_mount_shares.service that calls this script
    • I’ve created the /etc/systemd/system/auto_mount_shares.timer for the service, as described in the wiki. The only difference with the wiki is that I added AccuracySec=1s. Here is the timer definition:
    # /etc/systemd/system/auto_mount_shares.timer
    [Unit]
    Description=Check the network mounts
    
    [Timer]
    OnCalendar=*-*-* *:*:00
    AccuracySec=1s
    
    [Install]
    WantedBy=timer.target
    

    To test, I start the timer myself via systemctl start auto_mount_shares.timer and it works: The script is executed every minute and mounts / unmounts the shares depending on the network that I am connected to.

    I want this running automatically from startup, so I try to enable the timer. I get 2 authorization pop-ups and then an error message:

    $ systemctl enable auto_mount_shares.timer
    Failed to reload daemon: Message recipient disconnected from message bus without replying
    

    If I run the same command with sudo, I have no error message, but the timer is still not enabled (it does not appear in the output of systemctl list-timers)
    The next time I reboot, the timer is not running (regardless if the timer was enabled with sudo or without)

    This is happening on a brand-new installation of Antergos with KDE

    I hope you can help, thanks in advance.

  • @pigeontech said in Cannot enable systemd timer:

    systemctl enable auto_mount_shares.timer

    what is giving you:
    systemctl status auto_mount_shares.timer

  • @pigeontech said in Cannot enable systemd timer:

    auto_mount_shares.service

    systemctl status auto_mount_shares.service

  • @joekamprad : Wow, that was fast :) I’ll let you know in a few hours when I get home

  • Here are the outputs:

    $ systemctl status auto_mount_shares.timer
    ● auto_mount_shares.timer - Check the network mounts
       Loaded: loaded (/etc/systemd/system/auto_mount_shares.timer; enabled; vendor preset: disabled)
       Active: inactive (dead)
      Trigger: n/a
    

    and

    $ systemctl status auto_mount_shares.service
    ● auto_mount_shares.service - Check the network mounts
       Loaded: loaded (/etc/systemd/system/auto_mount_shares.service; static; vendor preset: disabled)
       Active: inactive (dead)
    
  • shows nothing more? so you will need to check journal:

    journalctl -b -0 | curl -F [email protected] https://ptpb.pw/?u=1

  • No, nothing more

    Here is the journalctl output:
    https://ptpb.pw/MJ2z

  • @joekamprad

    do not show anything failing related to your service/timer…

    systemctl list-timers
    

    will show details about timer

    journalctl | grep auto_mount_shares.service
    journalctl | grep auto_mount_shares.timer
    
  • My timer does not appear in the systemctl list-timers:

    $ systemctl list-timers
    NEXT                          LEFT                LAST                          PASSED     UNIT                         ACTIVATES
    Thu 2018-03-29 00:01:58 CEST  4h 30min left       Wed 2018-03-28 07:45:24 CEST  11h ago    logrotate.timer              logrotate.service
    Thu 2018-03-29 00:02:04 CEST  4h 30min left       Wed 2018-03-28 07:45:24 CEST  11h ago    shadow.timer                 shadow.service
    Thu 2018-03-29 00:03:15 CEST  4h 31min left       Wed 2018-03-28 07:45:24 CEST  11h ago    updatedb.timer               updatedb.service
    Thu 2018-03-29 00:04:51 CEST  4h 33min left       Wed 2018-03-28 07:45:24 CEST  11h ago    man-db.timer                 man-db.service
    Thu 2018-03-29 19:27:42 CEST  23h left            Wed 2018-03-28 19:04:25 CEST  26min ago  systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
    Sat 2018-04-07 15:00:00 CEST  1 weeks 2 days left Fri 2018-03-23 23:34:00 CET   4 days ago pamac-cleancache.timer       pamac-cleancache.service
    
    6 timers listed.
    

    It doesn’t even appear in the output of systemctl list-timers --all

    The 2 journalctl commands return some entries, but from before the reboot, so I’m not sure they are pertinent. As I said, I previously enabled the timer manually, to test that everything works. Here are the outputs:

    $ journalctl | grep auto_mount_shares.timer
    Mar 23 23:49:43 Eddie kactivitymanagerd[852]: Creating the cache for:  "/etc/systemd/system/auto_mount_shares.timer"
    Mar 23 23:49:43 Eddie kactivitymanagerd[852]: ResourceScoreUpdated: "44e74129-05d4-442e-a56f-b44e28e07e5a" "kate" "/etc/systemd/system/auto_mount_shares.timer"
    Mar 23 23:50:53 Eddie polkitd[500]: Operator of unix-session:c2 successfully authenticated as unix-user:rares to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-unit-files for system-bus-name::1.175 [systemctl enable auto_mount_shares.timer] (owned by unix-user:rares)
    Mar 23 23:50:58 Eddie polkitd[500]: Operator of unix-session:c2 successfully authenticated as unix-user:rares to gain TEMPORARY authorization for action org.freedesktop.systemd1.reload-daemon for system-bus-name::1.175 [systemctl enable auto_mount_shares.timer] (owned by unix-user:rares)
    Mar 23 23:52:27 Eddie polkit-kde-authentication-agent-1[732]: Message of action:  "Authentication is required to start 'auto_mount_shares.timer'."
    Mar 23 23:52:31 Eddie polkitd[500]: Operator of unix-session:c2 successfully authenticated as unix-user:rares to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.185 [systemctl start auto_mount_shares.timer] (owned by unix-user:rares)
    Mar 25 22:11:02 Eddie polkit-kde-authentication-agent-1[781]: Message of action:  "Authentication is required to start 'auto_mount_shares.timer'."
    Mar 25 22:11:08 Eddie polkitd[501]: Operator of unix-session:c2 successfully authenticated as unix-user:rares to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.98 [systemctl start auto_mount_shares.timer] (owned by unix-user:rares)
    Mar 28 07:45:59 Eddie polkitd[501]: Operator of unix-session:c2 successfully authenticated as unix-user:rares to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-unit-files for system-bus-name::1.1678 [systemctl enable auto_mount_shares.timer] (owned by unix-user:rares)
    Mar 28 07:46:04 Eddie polkitd[501]: Operator of unix-session:c2 successfully authenticated as unix-user:rares to gain TEMPORARY authorization for action org.freedesktop.systemd1.reload-daemon for system-bus-name::1.1678 [systemctl enable auto_mount_shares.timer] (owned by unix-user:rares)
    Mar 28 07:50:05 Eddie kactivitymanagerd[817]: Creating the cache for:  "/etc/systemd/system/auto_mount_shares.timer"
    Mar 28 07:50:05 Eddie kactivitymanagerd[817]: ResourceScoreUpdated: "44e74129-05d4-442e-a56f-b44e28e07e5a" "kate" "/etc/systemd/system/auto_mount_shares.timer"
    

    and

    $ journalctl | grep auto_mount_shares.service
    Mar 23 23:53:00 Eddie systemd[1884]: auto_mount_shares.service: Failed to execute command: Permission denied
    Mar 23 23:53:00 Eddie systemd[1884]: auto_mount_shares.service: Failed at step EXEC spawning /usr/local/bin/auto_mount_shares: Permission denied
    Mar 23 23:53:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=203/EXEC
    Mar 23 23:53:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'. 
    Mar 23 23:54:00 Eddie systemd[1899]: auto_mount_shares.service: Failed to execute command: Permission denied                                                                         
    Mar 23 23:54:00 Eddie systemd[1899]: auto_mount_shares.service: Failed at step EXEC spawning /usr/local/bin/auto_mount_shares: Permission denied                                     
    Mar 23 23:54:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=203/EXEC                                                                       
    Mar 23 23:54:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    Mar 23 23:55:00 Eddie systemd[1904]: auto_mount_shares.service: Failed to execute command: Permission denied                                                                         
    Mar 23 23:55:00 Eddie systemd[1904]: auto_mount_shares.service: Failed at step EXEC spawning /usr/local/bin/auto_mount_shares: Permission denied                                     
    Mar 23 23:55:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=203/EXEC                                                                       
    Mar 23 23:55:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    Mar 23 23:56:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a                                                                         
    Mar 23 23:56:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    Mar 27 17:35:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a                                                                         
    Mar 27 17:35:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    Mar 27 17:36:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a                                                                         
    Mar 27 17:36:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    Mar 27 17:37:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a                                                                         
    Mar 27 17:37:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    Mar 27 17:38:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a                                                                         
    Mar 27 17:38:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    Mar 27 17:39:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a                                                                         
    Mar 27 17:39:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.                                                                                         
    ..........
    ... more of the same ...
    ...........
    Mar 27 18:40:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a
    Mar 27 18:40:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.
    Mar 27 18:41:00 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a
    Mar 27 18:41:00 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.
    Mar 28 07:45:24 Eddie systemd[1]: auto_mount_shares.service: Main process exited, code=exited, status=32/n/a
    Mar 28 07:45:24 Eddie systemd[1]: auto_mount_shares.service: Failed with result 'exit-code'.
    

    Thanks again for taking the time to look into this

  • @pigeontech said in Cannot enable systemd timer:

    Failed to execute command

    may the /etc/systemd/system/auto_mount_shares.service is not executable?

    sudo chmod +x /etc/systemd/system/auto_mount_shares.service
    
  • Hi Joe,

    The Failed to execute command errors are from last week when I was setting this up.
    I’m pretty sure the script is executable. It’s one of the steps in the Wiki to do a chmod +x on the script, and I’ve run the script manually. I’ll check later today when I’ll be home.

    As I was saying in my first post, if I start the timer myself via systemctl start auto_mount_shares.timer, then everything works fine, the timer is enabled, appears in the systemctl list-timers output, it is triggered every minute, and runs the script successfully.

    What I don’t understand is the error that I get when I try to enable it via systemctl enable auto_mount_shares.timer and why it’s not starting automatically at boot

  • When you say it starts on booted system, then may it fails because network is not reachable at starting point on bootup.

    https://wiki.archlinux.org/index.php/NFS#NetworkManager_dispatcher

  • I’m not sure I understand. What you’re saying is that maybe the timer is actually being started at boot-up, but because the network is not yet available, the script fails and therefore the timer gets somehow disabled and is not triggered anymore ?

  • now when you asking this, it sound wrong to me… as enable a unit will only put it to a list, and it should stay there till you disable it…

    May take a look again and make sure you do not miss a step…

    https://wiki.archlinux.org/index.php/Systemd/Timers

    Also the maighty archwiki is going very complex on one hand and let you alone on stuff you can find in another wikipage… or simple is stuff an Archlinux user should know ;)

  • Hi Joe,

    I looked at the wiki, I tried some more, but then I just gave up.

    I installed cronie and I’m calling the auto_mount_shares script via cron. Works like a charm.

    Thanks for your help

systemd30 nfs4 timer1 Posts 15Views 601
Bloom Email Optin Plugin

Looks like your connection to Antergos Community Forum was lost, please wait while we try to reconnect.