• Scheduling a task with sysemd timers


    Hi, I am trying to get Grsync to run itself daily to backup some files in my “download” directory to an external usb powered drive. Grsync works fine manually and I have created a startup script with systemd timers which executes ok but then I get an error message as follows:
    "[[email protected] ~]$ systemctl start pkexecrsync.timer
    Job for pkexecrsync.timer failed.
    See “systemctl status pkexecrsync.timer” and “journalctl -xe” for details.
    [[email protected] ~]$"
    when I run “systemctl status pkexecrsync.timer” I get the following:
    "[email protected] ~]$ systemctl status pkexecrsync.timer
    ● pkexecrsync.timer - Run pkexecrsync daily
    Loaded: loaded (/etc/systemd/system/pkexecrsync.timer; static; vendor preset: disabled)
    Active: inactive (dead)
    Trigger: n/a

    Oct 29 09:32:17 shuttle systemd[1]: pkexecrsync.timer: Refusing to start, unit to trigger not loaded.
    Oct 29 09:32:17 shuttle systemd[1]: Failed to start Run pkexecrsync daily.
    Oct 29 09:51:02 shuttle systemd[1]: pkexecrsync.timer: Refusing to start, unit to trigger not loaded.
    Oct 29 09:51:02 shuttle systemd[1]: Failed to start Run pkexecrsync daily.
    Oct 29 10:00:25 shuttle systemd[1]: pkexecrsync.timer: Refusing to start, unit to trigger not loaded.
    Oct 29 10:00:25 shuttle systemd[1]: Failed to start Run pkexecrsync daily."

    also when I run “list-timers” action, I get the below:

    "[[email protected] ~]$ systemctl list-timers --all
    NEXT LEFT LAST PASSED UNIT A
    Mon 2017-10-30 00:00:16 GMT 13h left Sun 2017-10-29 00:01:48 BST 11h ago logrotate.timer l
    Mon 2017-10-30 00:00:39 GMT 13h left Sun 2017-10-29 00:03:48 BST 11h ago man-db.timer m
    Mon 2017-10-30 00:01:27 GMT 13h left Sun 2017-10-29 00:01:48 BST 11h ago updatedb.timer u
    Mon 2017-10-30 00:02:05 GMT 13h left Sun 2017-10-29 00:05:48 BST 10h ago shadow.timer s
    Mon 2017-10-30 07:23:28 GMT 21h left Sun 2017-10-29 07:23:28 GMT 2h 42min ago systemd-tmpfiles-clean.timer s
    Wed 2017-11-01 00:00:00 GMT 2 days left Fri 2017-10-27 21:19:34 BST 1 day 13h ago pamac-cleancache.timer p

    6 timers listed."

    which lists all the ones in systemd but not the one I created? Any ideas if this is something that can be fixed? Thanks

  • @philipmirabelli
    I’ve used crontab for my scheduled tasks. Can be found e.g. in package cronie.
    More help:

    man crontab
    

    Edit you cron jobs:

    crontab -e
    
  • @manuel Hi thanks, I will try crontab, the reason I tried systemd timers is that apparently its included in the antergos distro by default, at least that is what it says on the Archlinux wiki, thanks anyway!

  • @philipmirabelli
    To be honest, I haven’t tested cronie on my Antergos, but on other systems. But as far as I can tell, it should work as expected.
    So hopefully it works for you! :)

  • Hi @philipmirabelli. I need to see the contents of both your .timer and .service unit files and also need to know where you installed them to.

  • Hello, below is the content of the .timer file. As to the .service file I stupidly did not create one which is probably why the action is not happening. I will compile one and see if that works. In fact I didn’t fully read the Arch Wiki page…

    "[Unit]
    Description=Run pkexecrsync daily

    [Timer]
    OnCalendar=daily
    AccuracySec=12h
    RandomizedDelaySec=5m
    Persistent=true"

  • @philipmirabelli, let us know how it went.

sysemd1 scheduling1 timers2 task2 Posts 7Views 85
Log in to reply