当前位置:网站首页>The problem of writing go run in crontab does not execute
The problem of writing go run in crontab does not execute
2022-07-30 19:02:00 【geekqian】
Use crontab to run the script regularly on the server, using the go run command, the result is not executed
Reference:
https://www.cnblogs.com/mysticbinary/p/13371189.html
http://www.nfangbian.com/go/cmd/gobuild.html
I searched and found that the go run
command is only applicable to the debugging phase. If it is run on the server, it must be packaged into a binary file for execution.
Solution:
Executing the go build
command in the project directory will generate an executable file with the file name of the project, and add the parameter -o
You can specify the packaged file name, as follows
go build -o apple
It may also be necessary to pay attention to whether there is a permission problem. If not, use chmod 755 xxx
to escalate the privilege and execute it again.I'm using the root account so no problem.
Then write the direct executable file in crontab
.
Post me:
1 0 * * * cd /work/xxx && ./apple
边栏推荐
猜你喜欢
随机推荐
启动前台Activity
运营 23 年,昔日“国内第一大电商网站”黄了...
JS提升:Promise中reject与then之间的关系
第4章 控制执行流程
【hbuilder】运行不了部分项目 , 打开终端 无法输入指令
ROS 环境使用第三方动态链接库(.so)文件
猎豹移动终于递交年报:年营收7.85亿 腾讯持股16.6%
After 23 years of operation, the former "China's largest e-commerce website" has turned yellow...
怎么样的框架对于开发者是友好的?
Codeblocks + Widgets 创建窗口代码分析
JsonUtil基于字符串操作josn
MongoDB打破了原则引入SQL?
沉浸式体验科大讯飞2022消博会“官方指定产品”
2种手绘风格效果比较,你更喜欢哪一种呢?
【PHPWord】PHPOffice 套件之PHPWord快速入门
【刷题篇】计算质数
Delay queue optimization (2)
跨进程启动后台服务
常见链表题及其 Go 实现
Anaconda Navigator卡在loading applications