加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
sync.sh 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
chinnkarahoi 提交于 2020-12-27 14:27 . fix cron_wrapper
#!/bin/bash
trap 'cp /jd-scripts-docker/sync.sh /sync' Exit
(
exec 2<>/dev/null
set -e
cd /jd-scripts-docker
git pull
) || {
git clone https://github.com/chinnkarahoi/jd-scripts-docker.git /jd-scripts-docker_tmp
[ -d /jd-scripts-docker_tmp ] && {
rm -rf /jd-scripts-docker
mv /jd-scripts-docker_tmp /jd-scripts-docker
}
}
(
exec 2<>/dev/null
set -e
cd /scripts
git pull
) || {
git clone --branch=master https://github.com/lxk0301/jd_scripts.git /scripts_tmp
[ -d /scripts_tmp ] && {
rm -rf /scripts
mv /scripts_tmp /scripts
}
}
cd /scripts || exit 1
npm install || npm install --registry=https://registry.npm.taobao.org || exit 1
[ -f /crontab.list ] && {
cp /crontab.list /crontab.list.old
}
cat /etc/os-release | grep -q ubuntu && {
cp /jd-scripts-docker/crontab.list /crontab.list
crontab -r
} || {
cat /scripts/docker/crontab_list.sh | grep 'node' | sed 's/>>.*$//' | awk '
BEGIN{
print("55 */3 * * * bash /jd-scripts-docker/cron_wrapper bash /sync")
}
{
for(i=1;i<=5;i++)printf("%s ",$i);
printf("bash /jd-scripts-docker/cron_wrapper \"");
for(i=6;i<=NF;i++)printf(" %s", $i);
print "\"";
}
' > /crontab.list
}
crontab /crontab.list || {
cp /crontab.list.old /crontab.list
crontab /crontab.list
}
crontab -l
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化