[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-mcron] Command does not run if not in PATH when mcron starts
From: |
Mathieu Lirzin |
Subject: |
Re: [Bug-mcron] Command does not run if not in PATH when mcron starts |
Date: |
Sun, 08 Apr 2018 19:18:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Hello Pierre,
Pierre Neidhardt <address@hidden> writes:
> I have a custom script:
>
> ~/.local/bin/udpatedb-local
>
> An mcron job:
>
> (job '(next-hour)
> "updatedb-local")
>
> And a .profile:
>
> export PATH="$PATH:${HOME}/.local/bin"
>
> if command -v mcron >/dev/null 2>&1; then
> mcron &
> fi
>
> `mcron -s ...` output is correct but updatedb-local never runs.
> Now if I swap the following in my .profile:
>
> export PATH="$PATH:${HOME}/.local/bin"
>
> if command -v mcron >/dev/null 2>&1; then
> mcron &
> fi
>
> it seems to work.
I don't see the difference in the two versions of “.profile”, what
should be swapped?
> Is it possible that mcron tries to find the command when evaluating the
> job file rather than when executing it?
>
> If so, I'd suggest we turn off this behaviour as it can be rather
> confusing.
when passing a string as the ACTION paramater of ‘job’, mcron simply
executes ‘(system ACTION)’ with the environment of the ‘mcron’ process
plus some environment variables that might be added with
‘append-environment-mods’ in the mcron configuration files.
In your case the environment used when evaluating the job file and
executing ‘udpatedb-local’ should be the same.
> Not directly related, but does mcron log anything? It's hard to debug
> from the user end. Did I miss something from the manual?
That would be helpful, but ‘mcron’ is currently not logging anything.
if you want to debug the output without having access to the ‘mcron’
process file descriptors you can use something (ugly!) like:
--8<---------------cut here---------------start------------->8---
(use-modules (ice-9 popen)
(ice-9 textual-ports))
(job '(next-second)
(lambda ()
(call-with-output-file "/tmp/mcron-out"
(lambda (out)
(with-output-to-port out
(lambda ()
(with-error-to-port out
(lambda ()
(let* ((port (open-input-pipe "udpatedb-local"))
(str (get-string-all port)))
(close-pipe port)
(display str out))))))))))
--8<---------------cut here---------------end--------------->8---
Ideas or patches to support convenient logging are welcome.
Thanks.
--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37