Re: python3 script not running as root

2018-11-15 Thread Markus Rosjat

Hi Marc,

Am 15.11.2018 um 14:05 schrieb Marc Espie:

6.4, or snapshot ?

there was an unveil snafu with doas a few days ago.


6.4 release

--
Markus Rosjatfon: +49 351 8107224mail: ros...@ghweb.de

G+H Webservice GbR Gorzolla, Herrmann
Königsbrücker Str. 70, 01099 Dresden

http://www.ghweb.de
fon: +49 351 8107220   fax: +49 351 8107227

Bitte prüfen Sie, ob diese Mail wirklich ausgedruckt werden muss! Before you 
print it, think about your responsibility and commitment to the ENVIRONMENT



Re: python3 script not running as root

2018-11-15 Thread Marc Espie
On Thu, Nov 15, 2018 at 09:36:45AM +0100, Markus Rosjat wrote:
> Hi Martin and  Daniel,
> 
> Am 15.11.2018 um 09:24 schrieb Martin Sukany:
> >Hi,
> >
> >you'd fix this by defining PATH variable in your crontab, or specify the
> >full path to python3 interpreter instead using env.
> >
> as daniel also suggested I will try the the PATH crontab approach and this
> is because scripts with a full path in the shebang seem to run anymore on
> 6.4

6.4, or snapshot ?

there was an unveil snafu with doas a few days ago.



Re: python3 script not running as root

2018-11-15 Thread Ken M
On Thu, Nov 15, 2018 at 09:36:45AM +0100, Markus Rosjat wrote:
> as daniel also suggested I will try the the PATH crontab approach and this
> is because scripts with a full path in the shebang seem to run anymore on
> 6.4
> 
> regards
> 

Yeah just checked my scripts I was referring to (they are for systend on linux
system). but actually in the gunicorn example I do this:

Set the PATH variable to the .venv/bin
the exec line actually points to .venv/bin/gunicorn in this case and calls the
service by module name under that venv. I think I did it this way to specify
serving on a .sock. Can't remember.

Ken



Re: python3 script not running as root

2018-11-15 Thread Ken M
On Thu, Nov 15, 2018 at 09:24:10AM +0100, Martin Sukany wrote:
> Hi,
> 
> you'd fix this by defining PATH variable in your crontab, or specify the
> full path to python3 interpreter instead using env.
> 
> M>
> 
> 

As the others said, and to expand, it is probably from the shebang line of your
python script which you should not change. You just want cron to not use it. So
in short in yourscript.py the first line should be #!/usr/bin/env python3, you
should call the scipt in cron as such:

/usr/local/bin/python3 /path/to/yourscript.py

Also that would be the same way to do it in a service. The reason I say that is
the specific best solution is in case your python script has dependencies in a
.venv or a specific python version and you have multiple. So you can change the
above to be as such.

/path/to/project/.venv/bin/python /path/to/project/yourscript.py

I use that syntax for example to spawn gunicorn served microservices.

Ken



Re: python3 script not running as root

2018-11-15 Thread Markus Rosjat

Hi Martin and  Daniel,

Am 15.11.2018 um 09:24 schrieb Martin Sukany:

Hi,

you'd fix this by defining PATH variable in your crontab, or specify 
the full path to python3 interpreter instead using env.


as daniel also suggested I will try the the PATH crontab approach and 
this is because scripts with a full path in the shebang seem to run 
anymore on 6.4


regards

--
Markus Rosjatfon: +49 351 8107224mail: ros...@ghweb.de

G+H Webservice GbR Gorzolla, Herrmann
Königsbrücker Str. 70, 01099 Dresden

http://www.ghweb.de
fon: +49 351 8107220   fax: +49 351 8107227

Bitte prüfen Sie, ob diese Mail wirklich ausgedruckt werden muss! Before you 
print it, think about your responsibility and commitment to the ENVIRONMENT



Re: python3 script not running as root

2018-11-15 Thread Martin Sukany

Hi,

you'd fix this by defining PATH variable in your crontab, or specify the 
full path to python3 interpreter instead using env.


M>

On 11/15/18 8:39 AM, Markus Rosjat wrote:

Hi all,

I have a python script to get some traffic stats from my machines and 
it is running without problems except for a new installed OpenBSD 6.4 
machine. There I get following error:


env: python3: No such file or directory

This only happens when the cronjob is running when I run it from 
terminal with doas it works. That is kinda odd sice both root and my 
user have python3 and env in there $PATH at least the path to the 
executable.


some hints would be appreciated.

regards





Re: python3 script not running as root

2018-11-15 Thread Daniel Gracia
AFAIK cron won't spawn a login shell, so there are no 'env' variables
to start with. You could import a user's profile from the crontab and
get done with that (0 5 * * * . $HOME/.profile;
/path/to/command/to/run) but IMO best practice would require you to
set any variables in your cron script.

Regards!
El jue., 15 nov. 2018 a las 8:44, Markus Rosjat () escribió:
>
> Hi all,
>
> I have a python script to get some traffic stats from my machines and it
> is running without problems except for a new installed OpenBSD 6.4
> machine. There I get following error:
>
> env: python3: No such file or directory
>
> This only happens when the cronjob is running when I run it from
> terminal with doas it works. That is kinda odd sice both root and my
> user have python3 and env in there $PATH at least the path to the
> executable.
>
> some hints would be appreciated.
>
> regards
>
> --
> Markus Rosjatfon: +49 351 8107224mail: ros...@ghweb.de
>
> G+H Webservice GbR Gorzolla, Herrmann
> Königsbrücker Str. 70, 01099 Dresden
>
> http://www.ghweb.de
> fon: +49 351 8107220   fax: +49 351 8107227
>
> Bitte prüfen Sie, ob diese Mail wirklich ausgedruckt werden muss! Before you 
> print it, think about your responsibility and commitment to the ENVIRONMENT
>



python3 script not running as root

2018-11-14 Thread Markus Rosjat

Hi all,

I have a python script to get some traffic stats from my machines and it 
is running without problems except for a new installed OpenBSD 6.4 
machine. There I get following error:


env: python3: No such file or directory

This only happens when the cronjob is running when I run it from 
terminal with doas it works. That is kinda odd sice both root and my 
user have python3 and env in there $PATH at least the path to the 
executable.


some hints would be appreciated.

regards

--
Markus Rosjatfon: +49 351 8107224mail: ros...@ghweb.de

G+H Webservice GbR Gorzolla, Herrmann
Königsbrücker Str. 70, 01099 Dresden

http://www.ghweb.de
fon: +49 351 8107220   fax: +49 351 8107227

Bitte prüfen Sie, ob diese Mail wirklich ausgedruckt werden muss! Before you 
print it, think about your responsibility and commitment to the ENVIRONMENT