Re: Find the path of a shell command [POSTPONED]
On 2022-10-16 17:21:03 +0100, Barry wrote: > > On 16 Oct 2022, at 04:53, Dan Stromberg wrote: > > > > On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson wrote: > > > >>> On 13Oct2022 03:25, Paulo da Silva > >>> wrote: > >>> There is another problem involved. The script, works fine except when > >>> launched by cron! Why? [... script deleted ...] > >> Cron's environment is very minimal. This will show you what's in > >> it. > > > > Careful. On some systems if someone restarts the cron daemon, it could > > pick up a larger environment than after being started on boot. > > That have to a old system that does not use systemd. Systemd is specific to Linux - and not even used by all Linux distributions. > Is there a specific system that still does this? Not sure. Some Unixes I've used in the past (probably including some Linux distributions) had this problem. So you had to be a bit careful when restarting daemons from the command line. I think the sysVinit system used by most Linux distributions before systemd did clean up the environment if you used it correctly (but I'm not sure and have no system anymore to test it). I haven't used Solaris or HP/UX in a long time (and other Unixes even longer) so I don't know what they do these days. And I've never used MacOS, I just know that they've used a system of their own long before systemd. Anyway he doesn't have to restart cron to add a cron-job (nor for any other reason during normal operation), so what happens if you manually restart cron is almost certainly irrelevant for the OP. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Find the path of a shell command [POSTPONED]
> On 16 Oct 2022, at 04:53, Dan Stromberg wrote: > > On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson wrote: > >>> On 13Oct2022 03:25, Paulo da Silva >>> wrote: >>> There is another problem involved. The script, works fine except when >>> launched by cron! Why? >> >> Record the script output: >> >> # record all output >> exec >/tmp/script.$$.out 2>&1 >> # dump the envionment >> env | sort >> # turn on execution tracing >> set -x >> ... rest of the script >> >> and have a look afterwards. Cron's environment is very minimal. This >> will show you what's in it. >> > > Careful. On some systems if someone restarts the cron daemon, it could > pick up a larger environment than after being started on boot. That have to a old system that does not use systemd. Is there a specific system that still does this? Barry > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Find the path of a shell command [POSTPONED]
On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson wrote: > On 13Oct2022 03:25, Paulo da Silva > wrote: > >There is another problem involved. The script, works fine except when > >launched by cron! Why? > > Record the script output: > > # record all output > exec >/tmp/script.$$.out 2>&1 > # dump the envionment > env | sort > # turn on execution tracing > set -x > ... rest of the script > > and have a look afterwards. Cron's environment is very minimal. This > will show you what's in it. > Careful. On some systems if someone restarts the cron daemon, it could pick up a larger environment than after being started on boot. -- https://mail.python.org/mailman/listinfo/python-list
Re: Find the path of a shell command [POSTPONED]
On 13Oct2022 03:25, Paulo da Silva wrote: There is another problem involved. The script, works fine except when launched by cron! Why? Record the script output: # record all output exec >/tmp/script.$$.out 2>&1 # dump the envionment env | sort # turn on execution tracing set -x ... rest of the script and have a look afterwards. Cron's environment is very minimal. This will show you what's in it. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Find the path of a shell command [POSTPONED]
Às 05:00 de 12/10/22, Paulo da Silva escreveu: 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? For now I will postpone this problem. I just wrote a small script to delete a dir using rm and it works even under cron! There is another problem involved. The script, works fine except when launched by cron! Why? I'll have to look into this later when I have more time. For now I solved the problem using a complementary shell script. Thank you very much to those who responded. Paulo -- https://mail.python.org/mailman/listinfo/python-list