在启动时使用Linux运行python应用程序/脚本。

时间:2022-12-06 13:29:08

I've been learning Python for a project required for work. We are starting up a new server that will be running linux, and need a python script to run that will monitor a folder and handle files when they are placed in the folder.

我一直在为一个工作需要的项目学习Python。我们正在启动一个将运行linux的新服务器,并需要一个python脚本来运行,该脚本将监视文件夹并在文件放置到文件夹中时处理它们。

I have the python "app" working, but I'm having a hard time finding how to make this script run when the server is started. I know it's something simple, but my linux knowledge falls short here.

我让python“应用程序”正常工作,但是在服务器启动时,我很难找到如何让这个脚本运行。我知道这很简单,但我对linux的了解还不够。

Secondary question: As I understand it I don't need to compile or install this application, basically just call the start script to run it. Is that correct?

次要问题:根据我的理解,我不需要编译或安装这个应用程序,只需要调用start脚本就可以运行它。那是正确的吗?

1 个解决方案

#1


2  

You can set up the script to run via cron, configuring time as @reboot

您可以设置脚本通过cron运行,配置时间为@重启。

With python scripts, you will not need to compile it. You might need to install it, depending on what assumptions your script makes about its environment.

使用python脚本,您不需要编译它。您可能需要安装它,这取决于您的脚本对环境的假设。

#1


2  

You can set up the script to run via cron, configuring time as @reboot

您可以设置脚本通过cron运行,配置时间为@重启。

With python scripts, you will not need to compile it. You might need to install it, depending on what assumptions your script makes about its environment.

使用python脚本,您不需要编译它。您可能需要安装它,这取决于您的脚本对环境的假设。