Linux Crontab Pwd
背景: 使用 crontab -e 添加定时任务后, 发现任务没有如希望的执行, 发现要执行的命令是使用了相对路径引入文件, 推测是文件路径不正常 在 linux 中 root 用户执行命令 crotab -e 添加任务获取当前工作目录 * * * * * pwd >> ~/tmp.txt 2>&1 之后生成一新用户 # root 用户 # -m 生成用户同名 home 目录 useradd -m test passwd test # test 用户 同样新增获取 pwd 输出到其 home 目录的任务 crontab -e 经过执行发现, 在 /root/tmp.txt 文件中 pwd 输出为 /root 在 /home/test/tmp.txt 文件中 pwd 输出为 /home/test “The cron daemon starts a subshell from your HOME directory” 参考文档
Recent Posts
Tags
- apache 4
- axios 1
- benchmark 1
- c 1
- canvas 1
- centos 3
- channel 1
- crontab 1
- css 2
- docker 4
- fail2ban 1
- frp 1
- gin 1
- github 1
- go 26
- goaccess 1
- goroutine 1
- http 1
- https 1
- jetbrains 1
- jquery 1
- js 2
- linux 20
- mermaid 1
- mysql 10
- nginx 3
- node 1
- php 43
- prisma 1
- react 8
- server 1
- ssh 2
- tarojs 1
- tcp/ip 1
- token 1
- ubuntu 1
- ufw 1
- unit-test 1
- vmware 1
- vscode 1
- vue 12
- yum 1
- 域名 3
- 安全 2
- 微信 3
- 算法 3