왜 crontab 시스템 내 python 스크립트와 함께 새로운 PID[중복]

0

질문

했 python3 스크립트와 같은 것이 시작하는 그를 자동적 후 재부팅합니다. 그것은 시작하지만,그 시작으로 항상 새로운 PID,나는 그것을 확인하 ps aux. 을 시작하면 파일 터미널을 통해,그것은 바로 실행에서 같은 PID.

내가 사용하는 @재부팅이/usr/bin/python3/path/myFile.py 에 crontab

import sys

from cryptography import x509
sys.path.insert(0, "..")
import time


from opcua import ua, Server


if __name__ == "__main__":

    # setup our server
    server = Server()
    server.set_endpoint("opc.tcp://0.0.0.0:4842/freeopcua/server/")

    # setup our own namespace, not really necessary but should as spec
    uri = "http://examples.freeopcua.github.io"
    idx = server.register_namespace(uri)


    # get Objects node, this is where we should put our nodes
    objects = server.get_objects_node()

    # populating our address space
    myobj = objects.add_object(idx, "MyObject")
    startCali = myobj.add_variable(idx, "Start Calibration", True)
    brigthness = myobj.add_variable(idx, "Brightneess", 0.0)

    brigthness.set_writable()
    startCali.set_writable()    # Set MyVariable to be writable by clients
    oldstartCalivar = 0
    oldbrightnesss = 1.0
    
   
 

    # starting!
    server.start()
    
    try:
        count = 0
        while True:
            time.sleep(1)
            
            if brigthness.get_value () != oldbrightnesss:
                changeBrightness = "xrandr --output eDP-1 --brightness %f" % (brigthness.get_value()) 
            oldbrightnesss = brigthness.get_value()
                
                     
    finally:
        #close connection, remove subcsriptions, etc
        server.stop()
cron debian python
2021-11-18 13:43:18
1

최고의 응답

0

나는 그것을 해결과는 다른 방법:

https://stackoverflow.com/questions/51025312/start-a-python-script-at-startup-automatically

-->대답하여 Artsiom Praneuski

2021-11-18 15:43:30

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................