Cron support [systemd-crontab-generator]

Yes, systemd has timers. They work well.

But there are still quite a few packages which support cron, and their systemd.timer support is wonky at best.

Also, a single line in crontab, a single script in cron.daily etc… is mucheasier than 2 unit files [systemd.timer, systemd.service] with a few lines each, especially when you have a lot of cron tasks.

Yes, a cron daemon is redundant. I agree.
But there is a project which generates systemd units from cronjobs, automatically for the user.

The packages aren’t even there in the repos.

Please, fedora team, add them to the default installation. It will be immensely useful.

1 Like

Are you asking for these packages to help users migrate to systemd timers?

Personally I find systemd timers far easier to use then cron with it’s limitations.

Would you be willing to maintain the packages for these in Fedora?
Or maybe in copr?

systemd timers are far more flexible and granular, true.

But a cronjob for, say, some random one-line command is too simple in crontab, when compared to two systemd.{service,timer} units, each having atleast 3-6 lines.
[More functionality yes, but you just need the daily/hourly thing.]

This, being a trivially simple package, wouldn’t take much resources to be included in the base fedora default.

Atleast, one can copy off the unit files from /run/systemd/generator or wherever, for their purposes.

There are still many GUIs which many use, which just hook into user’s crontab.
These GUIs are stub, due to fedora’s lack of cronjob support.

systemd-cron with runparts disabled, and generator enabled, would efficiently provide the functionality of a cron daemon, with all features [mostly also has support for anacrontab].
But instead of a separate cron daemon, this just hooks into fully supported existing infrastructure, systemd timers and generators. So no excess code.

Just search in google to find out the complaints regarding the lack of cron on coreOS, kinoite etc…
But this will benifit to users of workstation and server too…

A simple generator, exter-systemd-packaged just like zram-generator, which provides full reliable and stable [in my experience on gentoo] support for cronjobs, without another forever-running daemon.
[Moreover, just to let the readers know, since the executables here are executed as systemd services, many environment-var-related problems etc… get solved.]

Are you willing to do the work? If not then it’s not likely it will be packaged.

can try.

I have prior experience with gentoo packaging, but not fedora. But I know the theoretical concepts.

Will be back here soon.

Happy to answer questions about rpm packaging.

1 Like

There’s already a specfile.

[Just confirmed, there is no package in the repos yet.]

I read the spec file and it seems to be a good starting point.
There where a couple of places that looked odd, but I think they are correct, given what the goal of the software is.

With that spec file and a source tar ball of code you should be able to make an RPM in your copr quickly for testing.

I don’t have a copr yet…

Also, I am locally testing 1st.

I just emailed to the maintainer on it.

If possible, I want the static run-parts to be packaged into another (sub)package, as the generator and run-parts are mutually exclusive,… and the generator will be preferred 99% of the time. But this is bottom priority.

1st, I prepared the sources with specfile -Rag systemd-cron.spec.

Then, rpmbuild -bb systemd-cron.spec

It complained of missing g++ in the middle of the build.
I installed it and addded it a BuildRequires: for it.

It compiled fine to a certain extent, ans is now failing with the following error:

/var/home/pramodvu/rpmbuild/BUILD/systemd-cron-2.5.0-build/systemd-cron-2.5.0/src/bin/systemd-crontab-generator.cpp:3:10: fatal error: md5.h: No such file or directory
    3 | #include <md5.h>
      |          ^~~~~~~
compilation terminated.
make: *** [Makefile:228: /var/home/pramodvu/rpmbuild/BUILD/systemd-cron-2.5.0-build/systemd-cron-2.5.0/out/build/bin/systemd-crontab-generator] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.PWvbXb (%build)

Plz… help ; IDK C/C++; I can just help in packaging.

It can be better to use a mock build becuase you then get the mandatory build deps installed in the mock environment.

You can use the dnf wildcard file installl feature to help with missing files.
For example try dnf install */md5.h to find a provider of that header.
But md5 is not a good choice for new code.

I am building in a toolbx container.
If a mock environment is something else, plz let me know.

I’ll try the wildcard trick and be back.

IDK why MD5 is used.

Back: ClanLib-devel is the package with the header.

Edit: no, header still not found. ClanLib-devel installed the header somewhere under /usr/include for C, but no such for C++ /usr/include/c++/14/ [only 14 directory is present].

mock is what is used to build RPMs in the Fedora world. It is not toolbox.

You need to dnf install mock and add your user to the mock group to make to use it.

Thanks
Will be back soon

Note: I use fedora Kinoite [atomic/immutable], and I am doing the mockery in the toolbox itself.

Successfully built SRPM using mock, and passed the SRPM to mock again.

It successfully builds, but then again fails at the same step md5.h.

I’ll cp /usr/include/md5.h /usr/include/c++/14/md5.h and try again [without mock 1st as I presume mock operates in it’s own chroot].

Edit: md5.h fount at /usr/include/ClanLib-2.3/ClanLib/Core/Crypto/md5.h.
Will try to copy over to expected locations and try. [No other package for md5.h elsewhere]

libmd-devel provides /usr/include/md5.h

Successfully built, with BuildRequires: libmd-devel

The github page specifies libmd as a dependency for a linker flag -lmd.

IDK if it is a build-time or runtime dependency, now I’m testing it on my main system.

Edit: Enabling run-parts means that the generator isn’t at all used. Am recompiling without runparts [--enable-runparts=no].
And enabled all the time granularity levels disabled by default.

Also the pre-bundled /etc/cron.weekly/systemd-cron cleanup cronjob needs to be chmod +x’d in the specfile.
[Thankfully, systemd-cron doesn’t generate timers for /etc/cron.*/ scripts which aren’t executable.]

Edit: There is already a timer unit for the cleanup, no need of the cronjob.

Everything works cohesively, no errors and issues.
Have accordingly updated the specfile.

Finally, it is available for installation as a copr.

Enable it with dnf copr enable pramodvu1502/systemd-cron.
And install systemd-cron
And enjoy crontab support.

1 Like

Also have applied for the package to be included in fedora.

It will be reviewed soon: 2350109 – Review Request: systemd-cron - systemd-generator implementing cronie and anacron

Glad you have got this into review.

Great news.

1 Like