Find the path of a shell command
Peter J. Holzer
hjp-python at hjp.at
Wed Oct 12 19:40:29 EDT 2022
On 2022-10-12 21:51:39 +0100, Paulo da Silva wrote:
> Às 19:14 de 12/10/22, Jon Ribbens escreveu:
> > If you're using subprocess.run / subprocess.Popen then the computer is
> > *already* searching PATH for you.
> Yes, and it works out of cron.
> > Your problem must be that your cron
> > job is being run without PATH being set, perhaps you just need to edit
> > your crontab to set PATH to something sensible.
The PATH in cron includes the directories with standard commands like
"rm" by default. If a cron job doesn't find rm, either
* rm isn't where it is supposed to be, or
* PATH has been changed.
> I could do that, but I am using /etc/cron.* for convenience.
That may be a clue. Does any of the /etc/cron.* files set PATH to weird
value?
In any case I find that when debugging such problems it is helpful to
find out what the actual environment is. A simple
* * * * * nobody echo $PATH >> /tmp/path.$$
should do that.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp at hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20221013/75919774/attachment.sig>
More information about the Python-list
mailing list