raspberry-pi - 无法使用 rc.local 和存档 .sh 运行 Django 应用程序
问题描述
嗨,我正在尝试在树莓上实现我的程序的自动执行,我阅读了一些教程,他们谈论使用扩展名为 .sh 的文件并编辑 rc.local 文件,我已经创建了名为 autorunser.sh 的文件并修改rc.local 文件,但它不起作用,我不知道我是否做错了什么,我用“源 autorunser.sh”调用 autorunser.sh 文件,程序可以工作,但我从 rc 调用。本地文件不起作用。
我在 rc.local 文件中的代码是这样的:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
source /home/pi/autorunser.sh
exit 0
我在 autorunser.sh 文件中的代码如下:
#!/bin/bash
cd /home/pi/pidjango/market
source ../djenv/bin/activate
python manage.py runserver
exit 0
解决方案
推荐阅读
- cookies - 阻止第三方 cookie 与同一站点 cookie
- go - 转义 URL Unicode 以在 go 模板中显示
- c - 从字符数组中提取一组字符/字符串
- css - 如何在 web 组件 shadow-dom 中设置根字体大小?
- python - pydub.AudioSegment.from_file 找不到文件
- scala - 使用 Monix 时,使用 mariadb 的 Quill.io 批量插入会引发错误
- opengl-es - 如何在 OpenGL ES 中使用两个浮点数模拟双精度?
- sql - 为什么这个查询会返回结果?
- java - 带有特殊字符的 Java 正则表达式
- lucene - Lucene:有没有办法快速估计查询的计数?