在启动时启动 python 脚本,然后加载 GUI



谁能告诉我如何在启动时启动python脚本,然后加载GUI?我是基于debian的Raspbian操作系统。

我想在启动时运行 python 脚本的原因是因为我需要从 RFID 阅读器读取键盘输入。我目前正在使用 raw_input() 从 RFID 阅读器读取数据。然后将 11 个字符的十六进制值与 txt 文件中的一组值进行比较。这个 raw_input() 对我使用 crontab 自动启动 python 脚本以及与 LXDE autostart 一起使用不起作用。

所以,我正在考虑在启动时运行python脚本,以便它读取键盘输入。如果有任何其他方法可以使用 crontab autostart 和 LXDE autostart 读取键盘输入,请告诉我。

将 bash 脚本添加到运行 python 程序的/etc/init.d 文件夹中。

#!/bin/sh
cd /path/to/program/
python2 program.py

然后:

# update-rc.d startMyPythonProgram.sh defaults 100
  • 默认值:运行级别设置
  • 100:优先级

资源: 这里

尝试在 crontab 中使用启动选项:

@reboot python/path/to/pythonfile.py

最新更新