Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Aug 2015 17:20:26 +0200
From:      "O. Hartmann" <ohartman@zedat.fu-berlin.de>
To:        freebsd-current <freebsd-current@freebsd.org>
Subject:   cron/python3: python script acts weird, no debug output
Message-ID:  <20150821172026.27b65c40@freyja.zeit4.iv.bundesimmobilien.de>

next in thread | raw e-mail | index | archive | help
I put this in this list, hopefully to find an answer.

Using a setup of NanoBSD as the platform for a small application written in
Python 3.4, which is supposed to run via cron and with UID of a special user, I
run into very nasty "non responsivnes" behaviour of the cron application.

The setup is simple, using NanoBSD built from CURRENT:
11.0-CURRENT FreeBSD 11.0-CURRENT #1 r286948: Thu Aug 20 05:50:45 CEST 2015
amd64

and double-checked setting of the OS running from an USB flash drive, / is r/w,
enough space left et cetera.

I managed to install packe lang/python3 and all of its dependencies as compiled
with the same base system as NanoBSD is built from - so from hereof no problems
should arise.

The python3 script comprises from several files, main.py and some files with
subroutines, all located in the same directory (~/bin) of a certain user's
home. The script looks for files on a memory files system backed folder/drive
and moves them, if any, towards a smbfs share provided by a M$ 2012R2 server,
mounted via autofs. So far, no problem.

Login as the specified user and running the script via "python3 bin/main.py"
works like a charme.

That specific user has an existing /var/cron/allow entry and
the /var/cron/tabs/user_foo file with the cronjob description exists, too. So
far, no irregularity.

When the job is run from cron, the situation changes dramatically. The setup is
like this:

SHELL=/bin/sh
TZ=Europe/Berlin
MAILTO=""
PATH=/usr/local/bin:/usr/local/sbin:${PATH}
*/1 * * * * /usr/local/bin/python3 /home/user_foo/bin/main.py --src /mfs/src \
-dst /mnt/server_slot

I tried also other variants, having in mind that cron has a very limited
inheritage of the environment, like 

*/1 * * * * cd /hom,e/user/foo/bin && /usr/local/bin/python3 main.py
--src /mfs/src \ -dst /mnt/server_slot

so the python3 script may find its pieces.

But whenever the cronjob starts, I see the first messages as output from the
script, some jumps into subroutines (I use classes from os, sys), but then,
suddenly, the output dies. Simply dies. this happens then when the job seems to
find files it should move. this is indicated by the fact that I printout 

Start (time):
End (time):

but END: (time) then never is seen on console or syslog (I delegate everything
with prio debug to console and a syslog server).

It looks like the python3 job suffers from severe lack in resources and isn't
capable of even send out some agony messages.

I'm floating like a dead man in the water and the rare hairs got more gray
coloured over the past days finding a solution. maybe I'm missing something
with cron/python3?

Hopefully someone finds the simple answer I'm seeking.

regards,

Oliver 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150821172026.27b65c40>