Control: tag -1 +confirmed

Hi,

I confirm your problem.

In v1.x the trailing "> /dev/null" was purposely chopped of the end of the line
because there wasn't an OnSucces= handler anyway and the goal
was to further parse the bash-one liner.

Some of the brittle bash-parsing has already been dropped of from 2.x.

We can either [1] remove the code that chop of the /dev/null
or [2] isolate it to only run when CRON_MAIL_SUCCESS=never
(a setting that allow users to revert to the previous behaviour).

I personally prefer "1" because of my own past habits
even if "2" will look cleaner from a new point of view..




--- a/src/bin/systemd-crontab-generator.cpp
+++ b/src/bin/systemd-crontab-generator.cpp
@@ -497,6 +497,9 @@ struct Job {
                        this->command.command0 = std::move(pgm);
                }

+               if(this->cron_mail_success != cron_mail_success_t::never)
+                       return;
                if(this->command.size() > 2 &&
this->command.command.e[-2] == ">"sv && this->command.command.e[-1] ==
"/dev/null"sv)
                        this->command.command.e -= 2;
                if(this->command.size() > 1 &&
this->command.command.e[-1] == ">/dev/null"sv)

Le mar. 12 sept. 2023 à 21:12, John Flinchbaugh
<j...@nucleus.hjsoft.com> a écrit :
> Dear Maintainer,
>
> I can put a simple command with a redirect to a file or /dev/null, and
> systemd-cron continues to email the output of the command. See the
> following excerpt from the email, which shows the command I'm running:

> 2023-09-12T18:44:00+0000 nucleus.hjsoft.com systemd[1]: Starting 
> cron-john-john-3.service - [Cron] "* * * * *   ls -la > /dev/null"...
>
> I would have not expected to see the output in email.
>
> Work-around:
> I can get the redirect to work, if I change the cron entry to:
> ----
> * * * * *   bash -lc "ls -la > /dev/null"

Reply via email to