python - 重启后 init.d 自动启动 python 脚本 (Centos)

标签 python linux centos init.d

重启后有任何一个自动启动python脚本的脚本(centos)。

我试过这段代码,但它不起作用

#! /bin/sh
# chkconfig: 2345 95 20
# description: almagest
# What your script does (not sure if this is necessary though)
# processname: www-almagest
# /etc/init.d/www-almagest start

case "$1" in
  start)
    echo "Starting almagest"
    # run application you want to start
    python ~almagest_clinic/app.py &> /dev/null &
    ;;
  stop)
    echo "Stopping example"
    # kill application you want to stop
    kill -9 $(sudo lsof -t -i:8002)
    ;;
  *)
    echo "Usage: /etc/init.d/www-private{start|stop}"
    exit 1
    ;;
esac

exit 0

chkconfig 脚本打开

最佳答案

我找到了解决方案 https://github.com/frdmn/service-daemons/blob/master/centos 绝对路径对我有用

关于python - 重启后 init.d 自动启动 python 脚本 (Centos),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22291908/

相关文章:

c - 在 Linux 中跟踪 pthreads?

python - PyQt 和 TCP/IP

python - 在 pygame 中查找 Sprite

linux - strace 将父 pid 关联到子 pid

android - 在 Android 上自定义/系统挂载点

python - 与 dbuser 不同的用户的 postgresql 身份验证失败

python - 为什么循环导入似乎在调用堆栈中更靠前,但在更靠下的位置引发 ImportError?

python - WebDriverException : Service U:/Scraping/chromedriver. exe 意外退出。状态代码为:1,同时使用 Chrome 和 Python

centos - sendmail 配置停止本地投递

centos - 全新 cPanel WHM 安装 - 无法登录