微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法使用 rc.local 和存档 .sh 运行 Django 应用程序

如何解决无法使用 rc.local 和存档 .sh 运行 Django 应用程序

嗨,我正在尝试在 raspBerry 上实现我的程序的自动执行,我阅读了一些教程,他们谈到使用带有 .sh 扩展名的文件并编辑 rc.local 文件,我已经创建了名为 autorunser 的文件。 sh 并修改 rc.local 文件,但它不起作用,我不知道我是否做错了什么,我使用“源 autorunser.sh”调用 autorunser.sh 文件并且程序可以运行,但是我的调用来自rc.local 文件不起作用。

我在 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。