linux中shell脚本手动执行没问题,crontab定时执行失败
可能是环境配置出问题
原本代码为
#!/bin/sh
cd /root/goItem/test
go run main.go
可在 #!/bin/sh 后加入 source /etc/profile 进行环境配置
#!/bin/sh
source /etc/profile
cd /root/goItem/test
go run main.go
这样即可解决问题
linux中shell脚本手动执行没问题,crontab定时执行失败
可能是环境配置出问题
原本代码为
#!/bin/sh
cd /root/goItem/test
go run main.go
可在 #!/bin/sh 后加入 source /etc/profile 进行环境配置
#!/bin/sh
source /etc/profile
cd /root/goItem/test
go run main.go
这样即可解决问题