Running a python script as a cron job in FreeBSD

后端 未结 1 959
我在风中等你
我在风中等你 2020-12-22 12:50

I\'m new to freeBSD. I just set up a server and installed python 3.6. Now i want to have a python script run every day at 15h00, so i tried to set up a cron task. But in so

相关标签:
1条回答
  • 2020-12-22 12:57

    To debug your environment add this to /etc/crontab

    * * * * * root env > ~/cronenv
    

    Wait for file ~/cronenv to be created (after a minute) and start a new shell using does environments:

    env - `cat ~/cronenv` /bin/sh
    

    Then call your script /usr/local/bin/python3.6 /root/myscript.py

    This will help to test/debug your code within the same environment cron is using.

    0 讨论(0)
提交回复
热议问题