start_stf.sh脚本如下:

#! /bin/sh

source $HOME/.zshrc
YMD=""$( date ""+%Y.%m.%d"" )""

if [ "$1" == "run" ]; then
    stf local --public-ip 192.168.203.50 --allow-remote 
else if [ "$1" == "start" ]; then
    nohup stf local --public-ip 192.168.203.50 --allow-remote >> ""logs/nohup_stf.out"" 2>&1 &
    echo "Application stf is starting."
else if [ "$1" == "stop" ]; then
    PID=$(ps -ef | grep stf | grep -v grep | awk '{ print $2 }')
    if [ -z "$PID" ]; then
        echo Application is already stopped
    else
        echo kill $PID
        kill $PID
    fi
else if [ "$1" == "status" ]; then
    PID=$(ps -ef | grep stf | grep -v grep | awk '{ print $2 }')
    if [ -z "$PID" ]; then
        echo Application is stopped
    else
        echo Application is running
        echo $PID
    fi
fi  
fi
fi
fi  

@reboot cd /Users/jane/stf; /bin/sh start_stf.sh start;

PS:以上脚本是复制后修改的,因为当时没保存出处,见谅。。
主要的还是这句:source $HOME/.zshrc
大概是因为当初装nvm的时候,配置自动更新到了.zshrc里吧
解决:crontab里 stf: no such file or directory

搞半天搞不定。。。瞎搞就好了。。也是妥妥得醉了。。
就做了笔记。。见谅。。

相关文章: