1 Star 0 Fork 10

dolpstar/plugin_linux_base

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
add_crontab.sh 915 Bytes
一键复制 编辑 原始数据 按行查看 历史
xrkmonitor 提交于 2021-05-29 11:37 . up
#!/bin/bash
script_path=''
script_name=''
function in_script_path()
{
echo "/" > _tmp
fc=`expr substr "$0" 1 1`
echo "$fc" > _tmp_2
cmp _tmp _tmp_2 > /dev/null 2>&1
if [ $? -eq 0 ];then
cscript=$0
else
cscript=$(pwd)/$0
fi
rm -f _tmp _tmp_2
script_path=`dirname $cscript`
script_name=`basename $cscript`
cd "$script_path"
}
in_script_path
crontab -l > _add_xrk_plugin_check_tmp
grep "${script_path}; \./cron_linux_base\.sh" _add_xrk_plugin_check_tmp > /dev/null 2>&1
if [ $? -eq 0 ]; then
rm _add_xrk_plugin_check_tmp
echo "already add"
exit 0
fi
curpwd=`pwd`
echo "*/1 * * * * cd ${script_path}; ./cron_linux_base.sh > /dev/null 2>&1" >> _add_xrk_plugin_check_tmp
crontab _add_xrk_plugin_check_tmp
if [ $? -eq 0 ]; then
rm _add_xrk_plugin_check_tmp
echo "add crontab ok"
exit 0
fi
echo "add to crontab failed"
rm _add_xrk_plugin_check_tmp
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/dolpstar/plugin_linux_base.git
git@gitee.com:dolpstar/plugin_linux_base.git
dolpstar
plugin_linux_base
plugin_linux_base
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385