Find the path of a shell command
Dan Stromberg
drsalists at gmail.com
Fri Oct 14 10:40:14 EDT 2022
On Wed, Oct 12, 2022 at 11:13 AM Paulo da Silva <
p_d_a_s_i_l_v_a_ns at nonetnoaddress.pt> wrote:
> Hi!
>
> The simple question: How do I find the full path of a shell command
> (linux), i.e. how do I obtain the corresponding of, for example,
> "type rm" in command line?
>
> The reason:
> I have python program that launches a detached rm. It works pretty well
> until it is invoked by cron! I suspect that for cron we need to specify
> the full path.
> Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin?
> What about other commands?
>
I like to test my cronjobs with something like:
env - /usr/local/bin/my-cronjob
This will empty out the environment, and force you to set $PATH yourself.
Alternatively, you can "ps axfwwe" (on Linux) to see environment variables,
and check what the environment of cron (or similar) is. It is this
environment (mostly) that cronjobs will inherit.
More information about the Python-list
mailing list