且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linux 在启动时运行

更新时间:2023-01-30 10:54:39

您很可能会遇到有关 cron 作业和 init 脚本的常见问题:环境变量未设置为您所期望的.

You have very likely run into a common problem with cron jobs and init scripts: the environment variables are not set to what you expect.

我建议明确设置变量.设置 PATH 和 HOME 值.如果 selenium 服务器需要 GUI,那么在您启动 Xvfb 之后,您需要设置 DISPLAY 和 XAUTHORITY.您可能还需要 USER.

I advise setting the variables explicitly. Set the PATH and HOME values. If selenium server needs a GUI then after you start Xvfb you need to set DISPLAY and perhaps XAUTHORITY. You might need USER as well.

对此的另一个评论:我不建议使用 cron 作业来执行此操作,尽管它会起作用.***使用 SysV init 脚本、Upstart 作业或 systemd 单元执行此操作,具体取决于您的 Pi 正在运行的内容.

Another comment on that: I don't recommend doing this with a cron job, although it'll work. It would be better to do this with a SysV init script, or Upstart job or systemd unit, depending on what your Pi is running.