crontab执行shell脚本

shell 脚本如下

复制代码
#!/bin/sh
source /etc/profile #需要导入环境变量,否则非原生命令执行不成功

procs=`ps -ef | grep python | grep aiphoto_data_maintain/bin/aiphoto_data | awk '{print $2}'`
for p in ${procs[@]}
do
    if [ "$p" != "" ]; then
        echo "kill $p"
        kill $p
    fi
done
sleep 3



echo "restarting ..."
#nohup python -u ai_photo/aiphoto_run.py -e Local -s https://aiphoto-test.howfun.tv -p 23288 > nohup.out 2>&1 &

ai_photo_data="/data2/yingjie/aiphoto_data_maintain/ai_photo_data_nohup.out"

if [ -f "$ai_photo_data" ]; then
rm "$ai_photo_data"
echo "remove log ..."
fi

nohup /data2/yingjie/aiphoto_data_maintain/venv/bin/python /data2/yingjie/aiphoto_data_maintain/bin/aiphoto_data.py > "$ai_photo_data" 2>&1 &
echo "aiphoto mongo success ..."



procs=`ps -ef | grep python | grep aiphoto_data_maintain/bin/photo_data | awk '{print $2}'`
for p in ${procs[@]}
do
    if [ "$p" != "" ]; then
        echo "kill $p"
        kill $p
    fi
done
sleep 3


photo_data="/data2/yingjie/aiphoto_data_maintain/photo_data_nohup.out"

if [ -f "$photo_data" ]; then
rm "$photo_data"
echo "remove log ..."
fi

nohup /data2/yingjie/aiphoto_data_maintain/venv/bin/python /data2/yingjie/aiphoto_data_maintain/bin/photo_data.py > "$photo_data" 2>&1 &
echo "photo_data mongo success ..."
复制代码

 

crontab 命令

08 13  * * * /bin/bash  /data2/yingjie/aiphoto_data_maintain/bin/back_mongo.sh

 

 

 

 

 

posted on   星河赵  阅读(996)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
历史上的今天:
2016-12-14 Linux 命令行模式 你需要知道的那些事
2016-12-14 解决 Django 后台上传图片前端无法展示

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示