-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd-crontab-generator generates cron.target.wants folder with nothing in it #115
Comments
Version? Distributor? Did |
Distributor is arch linux, built with a fixed PKGBUILD to update to release 2.0.2 # Maintainer: Dwayne Bent <dbb@dbb.io>
pkgname=systemd-cron
pkgver=2.0.2
pkgrel=1
pkgdesc='systemd units to run cron scripts'
arch=(any)
url='https://github.com/systemd-cron/systemd-cron'
license=('MIT')
depends=('systemd>=236' 'run-parts' 'python')
optdepends=('smtp-forwarder: sending emails')
provides=('cron')
conflicts=('cron')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/systemd-cron/${pkgname}/archive/refs/tags/v${pkgver}.tar.gz"
'sysusers.conf')
install=${pkgname}.install
sha256sums=('SKIP'
'SKIP')
prepare() {
cd "${srcdir}/${pkgname}-${pkgver}"
sed -i 's/print/echo/' ./configure # configure uses invalid shell cmds
}
build() {
cd "${srcdir}/${pkgname}-${pkgver}"
./configure --prefix=/usr --confdir=/etc --libexecdir=/usr/lib \
--enable-minutely --enable-quarterly --enable-semi_annually
make
}
package() {
cd "${srcdir}/${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" install
install -d "${pkgdir}"/etc/cron.{boot,minutely,hourly,daily,weekly,monthly,quarterly,semi-annually,yearly}
install -dm775 "${pkgdir}/var/spool/cron"
cat "${srcdir}/sysusers.conf" >> "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
}
strace output for command you asked:
yes, |
gonna quickly try to system update, because if it's just that this whole time i'm gonna die. i banged my head against this for 2 hours |
|
might poke the aur package maintainer about that, but they haven't updated since 1.16.7 so i don't expect a response |
Or just don't pass --confdir. The strace, very literally, does locale and iconv setup, then
You're configured with run-parts (which you probably shouldn't be for a modern config btw!), and: if(!USE_RUNPARTS) {
auto i = 0u;
for(auto period : {"hourly"sv, "daily"sv, "weekly"sv, "monthly"sv, "yearly"sv}) {
++i;
auto directory = "/etc/cron."s += period;
if(struct stat sb; stat(directory.c_str(), &sb) || !S_ISDIR(sb.st_mode))
continue;
for_each_file(directory.c_str(), [&](std::string_view basename) {
if(is_masked(directory.c_str(), basename, {std::begin(PART2TIMER), std::end(PART2TIMER)}))
return;
if(is_backup(directory.c_str(), basename))
return;
auto filename = (directory + '/') += basename;
std::string_view command = filename;
Job job{filename, filename};
job.persistent = true;
job.period = period;
job.start_hour = distro_start_hour[period]; // default 0
job.boot_delay = i * 5;
job.command = {{&command, &command + 1}, {}};
job.jobid = (std::string{period} += '-') += basename;
job.decode(); // ensure clean jobid
job.generate_schedule();
if(fallback_mailto && job.environment.find("MAILTO"sv) == std::end(job.environment))
job.environment.emplace("MAILTO"sv, *fallback_mailto);
job.unit_name = "cron-" + job.jobid;
job.output();
});
}
if(!parse_crontab("/etc/anacrontab", withuser_t::from_basename, /*monotonic=*/true, toplevel_mail_successful_output, toplevel_output_mail_format,
[&](auto && job) {
if(!job.valid) {
log(Log::ERR, "truncated line in /etc/anacrontab: %.*s", FORMAT_SV(job.line));
return;
}
generate_timer_unit(job);
}))
log(Log::ERR, "%s: %s", "/etc/anacrontab", std::strerror(errno));
if(struct stat sb; !stat(STATEDIR, &sb) && S_ISDIR(sb.st_mode)) {
// /var is available
for_each_file(STATEDIR, [&](std::string_view basename) {
if(basename.find('.') != std::string_view::npos)
return;
auto filename = (std::string{STATEDIR} += '/') += basename;
if(!parse_crontab(filename, withuser_t::from_basename, /*monotonic=*/false, toplevel_mail_successful_output, toplevel_output_mail_format,
[&](auto && job) { generate_timer_unit(job); }))
log(Log::ERR, "%s: %s", filename.c_str(), std::strerror(errno));
});
vore::file::fd<false>{REBOOT_FILE, O_WRONLY | O_CREAT | O_CLOEXEC, 0666};
} else {
if(!workaround_var_not_mounted())
log(Log::WARNING, "%s: %s", "cron-after-var.service", std::strerror(errno));
}
} Which looks an awful lot like I fucked up reading the python and included run-parts as being a precondition for processing users' crontabs ( |
Will comment that i specifically updated to 2.0.2 and systemd-crontab-generator on my install is not a python script |
Yes it's a trivial translation error on my part when converting the Python to C++. If you try the |
(also, you should probably configure with |
build warning with the only PKGBUILD change being depends=('systemd>=236' 'run-parts' 'python' 'mailcap') error:
also error is not fixed yet. will try to update |
missing option? |
oh it has to be enable-runparts ok |
Okay, in order:
If it still doesn't work on ded6dfc-or-later, then post the strace-as-root output again. |
--enable-runparts=no fixed the problem! will update pkgbuild to remove mailcap dependency, and figure out why the permissions are incorrect |
was just an incorrect arg in |
I just woke up 😁. The Was /etc/cron.d already ok in run-parts mode ? |
i never checked actually but i kinda don't wanna rebuild again, i just wanna get to using the program already |
I had if(!USE_RUNPARTS) {
for(auto period : {"hourly"sv, "daily"sv, "weekly"sv, "monthly"sv, "yearly"sv}) {
// /etc/cron.period/...
}
if(!parse_crontab("/etc/anacrontab", ...)
...;
if(struct stat sb; !stat(STATEDIR, &sb) && S_ISDIR(sb.st_mode)) {
// /var is avaible
for_each_file(STATEDIR, [&](std::string_view basename) {
// users' crontabs
}
} instead of if(!USE_RUNPARTS) {
for(auto period : {"hourly"sv, "daily"sv, "weekly"sv, "monthly"sv, "yearly"sv}) {
// /etc/cron.period/...
}
}
if(!parse_crontab("/etc/anacrontab", ...)
...;
if(struct stat sb; !stat(STATEDIR, &sb) && S_ISDIR(sb.st_mode)) {
// /var is avaible
for_each_file(STATEDIR, [&](std::string_view basename) {
// users' crontabs
} And never noticed (curse you python blocks being indent-only), fixed in ded6dfc. Functionally they are fine. The print thing is fixed in f3a13b5. |
Poke again :-) @dbent , the aur maintainer did initiated At first there weren't even a generator, only the static units with run-parts. For these reasons only I think that run-parts support should be retained. The lexical serialisation of jobs can also be really usefull in some settings. There are still a few Arch-only lines in the Makefile,
|
For readability you can use as many single-use functions like |
I figured a major version number change was a good opportunity to disable run-parts, but didn't consider serialized dependencies between scripts. I've added a note to the installation to warn users of this change.
These at least are handled by the package's install script (which I'm now realizing there's no way to view on the AUR web interface... you have to clone the package repository), so that can be removed from the generic Makefile. |
(arch stuff removed in 5d789e5) |
@dbent a new fixup release has been published |
>install systemd-cron
>crontab -e works, how nice!
>ok,
systemctl status cron-<tab>
-->huh. there's no cron-$USER-$USER-0.timer or cron-$USER-$USER-0.service
>okay, let's
sudo systemctl daemon-reload; sudo systemctl daemon-reexec
, that'll fix it>
systemctl list-timers --all
lists all cron-$schedule.target units, but nothing corresponding to my user>alright, let's
sudo systemctl start cron-update.service
>nothing changes
>manually call
/usr/lib/systemd/system-generators/systemd-crontab-generator ./
>get a folder,
./cron.target.wants/
, with nothing from my crontab reflectedam i using the program wrong? there are literally no errors telling me anything is going wrong. even the exit code it returns 0, literally nothing is wrong, except for a non-generated timer/service pair
The text was updated successfully, but these errors were encountered: