当前位置:网站首页>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
边栏推荐
- [Prometheus] An optimization record of the Prometheus federation [continued]
- (2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
- nlohmann json 使用指南【visual studio 2022】
- 2种手绘风格效果比较,你更喜欢哪一种呢?
- MySQL数据类型
- 中集世联达工业级成熟航运港口人工智能AI产品规模化应用,打造新一代高效能智慧港口和创新数字港口,全球港航人工智能能领军者中集飞瞳
- 《痞子衡嵌入式半月刊》 第 59 期
- 好未来单季营收2.24亿美元:同比降84% 张邦鑫持股26.3%
- WEBSOCKETPP使用简介+demo
- Range.CopyFromRecordset 方法 (Excel)
猜你喜欢
(2022杭电多校四)1001-Link with Bracket Sequence II(区间动态规划)
【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
Basic use of scrapy
OneFlow source code analysis: Op, Kernel and interpreter
cocos creater 热更重启导致崩溃
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!
深化校企合作 搭建技术技能人才成长“立交桥”
Immersive experience iFLYTEK 2022 Consumer Expo "Official Designated Product"
node封装一个控制台进度条插件
NC | 西湖大学陶亮组-TMPRSS2“助攻”病毒感染并介导索氏梭菌出血毒素的宿主入侵...
随机推荐
Anaconda Navigator stuck on loading applications
Critical Reviews | A review of the global distribution of antibiotics and resistance genes in farmland soil by Nannong Zou Jianwen's group
ROS 环境使用第三方动态链接库(.so)文件
Spark学习:用spark实现ETL
线性筛求积性函数
MongoDB打破了原则引入SQL?
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
卫星电话是直接与卫星通信还是通过地面站?
【Prometheus】Prometheus联邦的一次优化记录[续]
Recommended Books | Recommend 3 database books with rave reviews
积性函数
Swiper轮播图片并播放背景音乐
【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
vxe-table实现复选框鼠标拖动选中
natural language processing nltk
怎么样的框架对于开发者是友好的?
"Ruffian Heng Embedded Bimonthly" Issue 59
【每日一道LeetCode】——191. 位1的个数
常见链表题及其 Go 实现
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