当前位置:网站首页>crontab中写go run不执行的问题
crontab中写go run不执行的问题
2022-07-30 18:58:00 【geekqian】
在服务器上用crontab定时运行脚本,用的是 go run 命令,结果不执行
参考:
https://www.cnblogs.com/mysticbinary/p/13371189.html
http://www.nfangbian.com/go/cmd/gobuild.html
搜索了下发现go run
命令只适用于调试阶段,在服务器上跑的话要打包成二进制文件执行。
解决方案:
在项目目录下执行 go build
命令会生成以项目名为文件名的可执行文件,加参数 -o
可指定打包后的文件名,如下
go build -o apple
还有可能需要注意的是,要留意是否会有权限问题,如果不行就用 chmod 755 xxx
提权再执行看看。我使用的是root账户所以没问题。
之后在 crontab
中写直接执行文件即可。
贴个我的:
1 0 * * * cd /work/xxx && ./apple
边栏推荐
- 运营 23 年,昔日“国内第一大电商网站”黄了...
- OSPF详解(3)
- 《自然语言处理实战入门》---- 文本样本扩展小技巧:使用回译技术进行样本增强
- Chapter 4 Controlling the Execution Flow
- JsonUtil基于字符串操作josn
- The Meta metaverse division lost 2.8 billion in the second quarter!Still want to keep betting?Metaverse development has yet to see a way out!
- 使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
- SwiftUI iOS 精品开源项目之 完整烘焙食品菜谱App基于SQLite(教程含源码)
- Scala学习:breakable
- Redis for infrastructure
猜你喜欢
一文读懂“语言模型”
CCNA-ACL(访问控制列表)标准ACL 扩展ACL 命名ACL
微信小程序云开发 | 城市信息管理
猎豹移动终于递交年报:年营收7.85亿 腾讯持股16.6%
6 yuan per catty, why do Japanese companies come to China to collect cigarette butts?
【总结】1396- 60+个 VSCode 插件,打造好用的编辑器
C# wpf 无边框窗口添加阴影效果
【Pointing to Offer】Pointing to Offer 18. Delete the node of the linked list
Swiper rotates pictures and plays background music
生物医学论文有何价值 论文中译英怎样翻译效果好
随机推荐
一文读懂“语言模型”
JS提升:Promise中reject与then之间的关系
Spark学习:用spark实现ETL
线性筛求积性函数
CCNA-网络汇总 超网(CIDR) 路由最长掩码匹配
CIMC Shilian Dafeitong is the global industrial artificial intelligence AI leader, the world's top AI core technology, high generalization, high robustness, sparse sample continuous learning, industri
Swiper rotates pictures and plays background music
Chapter 14 Type Information
"Ruffian Heng Embedded Bimonthly" Issue 59
natural language processing nltk
Fixed asset visualization intelligent management system
Node encapsulates a console progress bar plugin
Read the "Language Model" in one article
C# wpf borderless window add shadow effect
MySql中@符号的使用
【总结】1396- 60+个 VSCode 插件,打造好用的编辑器
NC | Tao Liang Group of West Lake University - TMPRSS2 "assists" virus infection and mediates the host invasion of Clostridium sothrix hemorrhagic toxin...
高精度加法
2种手绘风格效果比较,你更喜欢哪一种呢?
Range.CopyFromRecordset 方法 (Excel)