CRON and Script aren't working together.

  • QA Engineer

    I have a violin on a python that works at the corners in the consoles. Crypt in the console:

    cd /root/bill
    source bin/activate

    The violin itself has a logic: running on the table in the mongo, getting HTML, generating a PDF from it, and clicking the tape as completed:

    # 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!


    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 (">>>>>>")
    print ("!!!!!!!")

    I'm trying to launch this eternal crypt in the crown by team:

    @reboot /root/bill/bin/python /root/bill/ >>/var/log/syslof

    I get 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 <==
    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 offset -0.344170 sec
    Jul 22 04:27:16 bill2 ntpdate[1281]: adjust time server offset -0.000024 sec

    I understand the violin goes somewhere on the line:

    pdfkit.from_string(doc.dokstring, doc.outpdf)

    But why does the console do what you need?

    All I've learned is that the crown has some sort of environment that doesn't see the file system or the library. pdfkit, though I'm starting it from the mouth.

  • Based on the line source bin/activate - you're using. virtualenv Or his fork/clon. virtualenv - is a separate environment with other ways in which modules that are not available in a system-based python can be installed (cot is default for all UNIX users)

    So make wrapper-file, where the right environment can be established:


    export VIRTUAL_ENV=/root/bill
    source $VIRTUAL_ENV/bin/activate
    $VIRTUAL_ENV/bin/python /path/to/

    and start it out. CRONTABYeah.

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2