Hello! help a novice understand where to dig: 1. I have a python script that in the console from the environment works out with a bang for launching the script in the console:
cd /root/bill source bin/activate puthon filegen.py
script text: (logic: run on the table in mongo, get HTML, generate a PDF from it and bang the record as done)
#!/root/bill/bin/python # coding: utf-8 from __future__ import unicode_literals from mongoengine import * import datetime import time import calendar from io import BytesIO as IO import gzip import pdfkit import pytils from bson import json_util from bson.json_util import dumps from bson.objectid import ObjectId import sys import random reload(sys) # Reload does the trick! sys.setdefaultencoding('UTF8') connect(host='mongodb://main:PWD@HOST/bill?ssl=true&ssl_cert_reqs=CERT_NONE') class Genq(Document): dokstring = StringField() outpdf = StringField() print ("started") foreva = True while foreva: print ("....") reqs = Genq.objects() for doc in reqs: print ("++++++") pdfkit.from_string(doc.dokstring, doc.outpdf) print (">>>>>>") doc.delete() print ("!!!!!!!")
Trying to run this eternal script in the crown with the command:
@reboot /root/bill/bin/python /root/bill/filegen.py >>/var/log/syslof
I receive the following message in the console:
root@bill2:~# tail 50 /var/log/syslog tail: cannot open '50' for reading: No such file or directory ==> /var/log/syslog <== started .... ++++++ Jul 22 04:26:56 bill2 postfix/pickup[1115]: C16891600F3: uid=0 from=<root> Jul 22 04:26:56 bill2 postfix/cleanup[1263]: C16891600F3: message-id=<20160722082656.C16891600F3@bill2> Jul 22 04:26:56 bill2 postfix/qmgr[1116]: C16891600F3: from=<root@bill2>, size=1221, nrcpt=1 (queue active) Jul 22 04:26:56 bill2 postfix/local[1265]: C16891600F3: to=<root@bill2>, orig_to=<root>, relay=local, delay=0.02, delays=0.01/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox) Jul 22 04:26:56 bill2 postfix/qmgr[1116]: C16891600F3: removed Jul 22 04:27:00 bill2 ntpdate[603]: step time server 91.189.89.198 offset -0.344170 sec Jul 22 04:27:16 bill2 ntpdate[1281]: adjust time server 91.189.89.198 offset -0.000024 sec root@bill2:~#
As I understand the script goes somewhere in a line
pdfkit.from_string(doc.dokstring, doc.outpdf)
But why does it work out of the console as needed?
All I understand is that the fact is that the crown has its own environment, from which either the file system is not visible, or the pdfkit library is not visible, although I run everything from the root
Help please with practical advice. thank
os.mknod('/var/www/output/123.pdf')
commandos.mknod('/var/www/output/123.pdf')
when I started it in the console - it creates, I reboot, it starts via kroner and throws again the .IOError rights to / var / www / output / three sevens - Sebulba Kastorsky