Crontab定时任务使用 Li.010

1. 使用Crontab的原因. 每次更新博客都要登录服务器(ssh延迟容易中断)手动去拉取代码, 不方便. 故设置成自动获取最新代码. 2. 选择crontab定时 查看下资源, 觉得crontab简单可行, 直接来用就好了. 3. 定时任务需需要做事情. 特定目录执行git pul的shell脚本. 这里配置ssh key vim git_pull.sh #!/bin/bash # 进入目录中 cd ~/nginx-hugoBlog/lizicai.com/ # 拉取github中的代码 git pull 添加crontab任务文件 vim git_pull.cron 设置5分钟拉取一次代码 */5 * * * * cd /root && ./git_pull.sh 把定时任务文件内容加到crontab中 # 添加root账户中 crontab -uroot git_pull.cron # 查询当前任务, root是账户, 添加的定时任务会放到这个目录中 crontab -uroot -l cat /var/spool/cron/root # 删除root用户的定时任务 crontab -uroot -r 日志的地址, 相当重要. # 日志文件 /var/spool/mail/root # 查看日志 # 可以把时间设置1分钟, 可以很快看到执行情况, 方便调试....

July 21, 2021 · 1 分钟 · Lizicai

Ag Fasd Fzf终端模糊搜索神器 Li.009

ag比grep快速的速度, 同时打印出搜索词的行数. Fasd 时空机, 瞬间跳到去过的目录, 或定位打开过的文件. Fzf 模糊搜索工具. 1. 安装ag fasd fzf 1.1 Mac安装ag fasd fzf. brew install the_silver_searcher fzf fasd # 以下内容添加到~/.zshrc或~/.bashrc中 eval "$(fasd --init auto)" # 重新生效 source ~/.zshrc 或 source ~/.bashrc 1.2 Linux安装ag fasd fzf. yum install the_silver_searcher fasd git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf ~/.fzf/install 2. 别名 alias jan='fasd -a' # any alias js='fasd -si' # show / search / select alias jd='fasd -d' # directory alias jf='fasd -f' # file alias jsd='fasd -sid' # interactive directory selection alias jsf='fasd -sif' # interactive file selection alias j='fasd_cd -d' # cd, same functionality as j in autojump alias jz='fasd_cd -d -i' # cd with interactive selection alias jdd='fasd -D' # 删除一个路径 alias v='jf -e vim' alias nv='jf -e nvim' alias catf='jf -e cat' alias py3f="jf -e python3" alias lsf="jd -e ls" alias shf='jf -e sh' alias commandf='jf -e command' # preview file alias ffp='fzf --preview '"'"'[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (rougify {} || highlight -O ansi -l {} || coderay {} || cat {}) 2> /dev/null | head -500'"'" # 跳到最近匹配的目录中 jj() { [ $# -gt 0 ] && fasd_cd -d "$*" && return local dir dir="$(fasd -Rdl "$1" | fzf -1 -0 --no-sort +m)" && cd "${dir}" || return 1 } jje() { [ $# -gt 0 ] && fasd_cd -d "$*" && return local dir dir="$(fasd -Rdl "$1" | fzf -e -1 -0 --no-sort +m)" && cd "${dir}" || return 1 } # 从当前路径搜索并跳转 jcd() { local dir dir=$(find ${1:-....

July 20, 2021 · 2 分钟 · Lizicai