首页 > 解决方案 > 无法使用 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

标签: raspberry-pishraspbian

解决方案


推荐阅读