Jump to content
  • 0

Migrating the cron jobs to systemd timers





I have uninstalled cron from my system completely, but I just thought I might help contribute, even just a little, by making some services and timer files to replace the ones in these folders:




Now keep in mind that I have not fully tested any of these yet! I would appreciate feedback in testing these, since most of these I won't even use on my system. I barely even use the armbian-config utility at all, so... yeah...


The files in question are these. Let me know if I should add more:




These are the Armbian specific ones. I know there's ones for like man-db, mdadm, logrotate, fake-hwclock and a bunch more that get installed by default. And I think systemd already has timer files for some of these. In fact, here's the timers in use on my Kobol system right now:


# systemctl list-timers
NEXT                        LEFT          LAST                        PASSED      UNIT                         ACTIVATES
Sat 2021-09-11 18:43:28 PDT 13min left    Fri 2021-09-10 18:43:28 PDT 23h ago     systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Sun 2021-09-12 00:00:00 PDT 5h 29min left Sat 2021-09-11 04:38:49 PDT 13h ago     logrotate.timer              logrotate.service
Sun 2021-09-12 00:00:00 PDT 5h 29min left Sat 2021-09-11 04:38:49 PDT 13h ago     man-db.timer                 man-db.service
Sun 2021-09-12 05:57:58 PDT 11h left      Sat 2021-09-11 17:25:28 PDT 1h 4min ago apt-daily.timer              apt-daily.service
Sun 2021-09-12 06:20:19 PDT 11h left      Sat 2021-09-11 06:59:08 PDT 11h ago     apt-daily-upgrade.timer      apt-daily-upgrade.service
n/a                         n/a           Sat 2021-09-11 05:57:28 PDT 12h ago     update-ddns.timer            update-ddns.service

6 timers listed.
Pass --all to see loaded but inactive timers, too.


The "update-ddns" timer and service is my own custom one. The rest are defaults.


So we'll start in order of shortest to longest activation times:


armbian-truncate-logs (runs every 15 minutes)








Description=Truncate the Armbian log files




armbian-updates (runs daily and on boot up)

Note: We are going to change this to run after the network is brought Online, but still make it run daily.








Description=Check for updates on the Armbian system




armbian-ram-logging (runs daily)

Note: It is mentioned that this cron job should only run when logrotate is a cron job. This was confusing wording at first, because it doesn't tell you if it prefers to either have logrotate as a systemd timer, or if logrotate should not run at all.


After looking inside the script "/usr/lib/armbian/armbian-ramlog", which passes "write" as the first argument, I tried to see if there was any problematic code that conflicts with logrotate...


Using the "syncToDisk ()" function, it doesn't seem like it'd conflict with logrotate at first glance.


Just to be safe, I've included the line "Conflicts=logrotate.service" just in case. If this can be safely removed, let me know.








Description=Perform Armbian RAM logging

ExecStart=/usr/lib/armbian/armbian-ramlog write





That's about it. Again, not sure if any of these should be set to "oneshot" or "simple" services, or if they need to be active "RemainOnExit" or whatnot. Just hope I can give a good template for converting cron jobs to systemd timers. It's a lot simpler than I thought to convert them.


Have a wonderful day, Armbian team. And thank you for all you contribute to this project.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Donate your old hardware to community. Start a giveaway Raffle!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines