美文网首页
jupyter自启动脚本

jupyter自启动脚本

作者: StephenZhang01 | 来源:发表于2018-07-29 19:53 被阅读0次

作用:Linux系统启动并自动运行jupyter服务,可查看运行状态、启动或停止。

在/etc/init.d/下创建一个脚本文件,名称自拟。

#! /bin/bash

# jupyter      Bring up/down/#

# chkconfig: 2345 10 90

# description: jupyter controller

[ -f /etc/init.d/functions ] && . /etc/init.d/functions

case $1 in

    start)

        jus=$(netstat -luntp| grep 8888 |grep -v grep|awk '{print $7}'|awk -F "/" '{print $1}'|wc -l)

        if [ $jus -eq 1 ];then

            echo -e "\njupyter is already run\n"

            exit 0

        else

            su - python -c "cd /tmp/test1 && jupyter notebook --ip=0.0.0.0 &"

            action "jupyter >>>\t$1 " /bin/true

        fi

        ;;

    stop)

        pkill jupyter && action "jupyter >>>\t$1 " /bin/true

        ;;

    status)

        stat=$(netstat -luntp|grep 8888|wc -l)

        if [ $stat -eq 1 ];then

            echo -e "\njupyter already run\n"

        fi

        ;; 

    *)

        echo "please use [start|stop|status]"

        exit 0

esac

最后将该脚本加入到系统启动服务。linux内核3.x与linux内核2.x服务启动方式不同,需注意。

相关文章

网友评论

      本文标题:jupyter自启动脚本

      本文链接:https://www.haomeiwen.com/subject/mtjtvftx.html