首页 > 系统相关 >crontab执行shell脚本

crontab执行shell脚本

时间:2022-12-14 13:23:21浏览次数:39  
标签:脚本 bin shell aiphoto yingjie photo crontab maintain data

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

 

 

 

 

 

标签:脚本,bin,shell,aiphoto,yingjie,photo,crontab,maintain,data
From: https://www.cnblogs.com/zhaoyingjie/p/16981791.html

相关文章