Skip to content

Commit

Permalink
feat: cron的docker
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Apr 22, 2024
1 parent 1ba6a4d commit 3f96acc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ sudo apt-get install -y wget unzip fontconfig locales gconf-service libasound2 l
docker-compose logs -f
```

### 2.定时运行(目前存在问题)
### 2.定时运行

```sh
docker-compose -f cron-docker-compose.yml up -d

0 6 * * * /root/auto-read-liunxdo/cron.sh # 注意这是示例目录,要改为所在仓库目录的cron.sh(使用pwd查看所在目录)
```
Empty file added cron.log
Empty file.
19 changes: 19 additions & 0 deletions cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# 获取当前工作目录
WORKDIR=$(dirname $(readlink -f $0))

# 进入工作目录
cd $WORKDIR

# 停止 Docker Compose
/usr/local/bin/docker-compose down

# 重新启动 Docker Compose
/usr/local/bin/docker-compose up -d >> ./cron.log 2>&1

# 等待10分钟
sleep 10m

# 停止 Docker Compose
/usr/local/bin/docker-compose down >> ./cron.log 2>&1

0 comments on commit 3f96acc

Please sign in to comment.