正在顯示「 2021 年 4 月 」的所有結果
4月 30, 2021 Docker
### Create Bash script

You may simple use the following code to save as a bash script to clear docker log.

```sh
#!/bin/bash -e

if [[ -z $1 ]]; then
    echo "No container specified"
    exit 1
fi

if [[ "$(docker ps -aq -f name=^/${1}$ 2> /dev/null)" == "" ]]; then
    echo "Container \"$1\" does not exist, exiting."
    exit 1
fi

log=$(docker inspect -f '{{.LogPath}}' $1 2> /dev/null)
truncate -s 0 $log
```

### Usage

Use `docker ps` to list each docker container and find their id's.

```sh
$ docker ps
```

Clear docker log by provide docker name as first parameter of the script.

```sh
$ ./docker-clear-log my-nginx-container
```

Enjoy : )
4月 30, 2021 AWS EC2
### On AWS

To resize the root volume of an EC2 instance, you can do the following steps:

1. Login to AWS console, navigate to "EC2" .

2. Select an instance.

![](https://cdn.19site.net/files/ed/0d/ed0d49e9-5aff-4ddb-ac6a-7ea39d4e453a.png)

3. Click the "Storage" tab.

![](https://cdn.19site.net/files/f6/5f/f65f7de2-232b-4396-8b1f-9222b845a04b.png)

4. Click on the volume that you want to resize.

![](https://cdn.19site.net/files/29/e6/29e6658b-2aa2-4094-b39c-4451756c3203.png)

5. Then you may redirected to volumes listing page, select the target volume and click "Action > Modify Volume".

![](https://cdn.19site.net/files/9f/0f/9f0f7bd3-9506-4bfa-b68e-96bc77676df1.png)

6. Now you may resize the volume.

![](https://cdn.19site.net/files/d5/76/d576404b-25e4-4a14-af48-bd05612a6016.png)

### On your EC2 instance

To take effect on your EC2 instance, you may do some action on you instance:

> Reference: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html#extend-file-system

1. Use `df -h` check the current disk mount points and partition.

2. Use `lsblk` to check disk and partitioning.

3. Use `sudo growpart /dev/xvda 1` to grow the partition to use entire disk spaces.

4. Use `lsblk` to check the result.

5. Use `sudo resize2fs /dev/xvda1` to extend the volume of partition.

Enjoy : )
4月 30, 2021
### glogg

glogg 的官方網站

[https://glogg.bonnefon.org/](https://glogg.bonnefon.org/)

這個工具可以開啟數十 GB 的 log file,看似無論檔案多大它好像也能夠開啟 ! 配合使用 Regular Expression 來找出想要看的行數,真的是睇 log 無難度 !
4月 30, 2021 MySQL
要 Backup MySQL DB 可以有好多種不同的方法,這次是使可比較可以 automate 的方法來進行 Backup 工作。

### mysqldump

mysqldump 其實是一個指令,用來連接 MySQL DB 並把輸出變成為一個 .sql 檔案備份。

以下的指令會完整的備份整個 DB 到 .sql 檔案內。

```sh
$ mysqldump -u {USER} -p -h {HOST} --port={PORT} --databases {DATABASE NAME} > /path/to/backup.sql
```

如果只是想備份 Databse 的架構,而不需要資料的話,可以使用以下的指令。

```sh
$ mysqldump -u {USER} -p -h {HOST} --port={PORT} --no-data --databases {DATABASE NAME} > /path/to/backup.sql
```

主要是加入了 `--no-data` 來達成。

4月 28, 2021 CSS
可以通過以下的 CSS 來達成,原理是使用了多重的文字陰影。

```css
.text-border {
	textShadow: '2px 0 0 #FFFFFF, -2px 0 0 #FFFFFF, 0 2px 0 #FFFFFF, 0 -2px 0 #FFFFFF, 1px 1px #FFFFFF, -1px -1px 0 #FFFFFF, 1px -1px 0 #FFFFFF, -1px 1px 0 #FFFFFF';
}
```
4月 28, 2021 Linux
當你在 Linux 上啟動 expo service 時,有可能會遇到以下的問題。

> System limit for number of file watchers reached watch expo

原因是因為 Linux 上是使用 `inotify` 來接收檔案變更的事件,以達成 Watch 功能。但是當要 watch 的檔案到達上限時,就會出現上面的 Error。

### 解決方法

我們可以通過加大 Watch 的檔案數量來解決:

開啟設定檔。

```sh
$ sudo gedit /etc/sysctl.conf
```

在檔案的最底下加入這句,然後儲存。

```sh
fs.inotify.max_user_watches=524288
```

可以用以下指令來查看變更後的情況。
```sh
sudo sysctl -p
```

完成後就能夠順制啟動了

![](https://cdn.19site.net/files/e2/d9/e2d93dee-700e-4d26-94bd-9f1a381c3253.png '能順利啟動')
過去文章
2025 (9)
4 (5)
3 (1)
2 (3)
2024 (25)
11 (3)
10 (3)
9 (1)
3 (18)
2022 (6)
10 (1)
6 (2)
5 (1)
3 (1)
1 (1)
2021 (21)
11 (7)
7 (1)
6 (2)
5 (2)
4 (6)
3 (2)
2 (1)
2020 (92)
12 (1)
11 (2)
10 (4)
9 (10)
8 (5)
7 (1)
6 (3)
5 (1)
4 (4)
3 (25)
2 (7)
1 (29)
2019 (57)
12 (25)
11 (7)
9 (25)