美文网首页Go
Linux下Golang编译程序在后台运行及开机启动

Linux下Golang编译程序在后台运行及开机启动

作者: 承诺一时的华丽 | 来源:发表于2019-05-07 21:43 被阅读0次
编译
> go build test.go 
指定输出文件名
> go build -o custom_name
修改可执行权限
> chmod 777 程序名称
程序后台运行
> nohup ./custom_name & 
不输出错误信息
> nohup ./custom_name >/dev/null 2>&1 &
关闭程序
  • 查询进程号
> ps aux|grep custom_name 
  • 关闭进程
> kill 进程编号
开机启动glang
> vi /etc/rc.local

添加

cd [程序路径,如:/home/website/www/]
nohup ./custom_name&

相关文章

网友评论

    本文标题:Linux下Golang编译程序在后台运行及开机启动

    本文链接:https://www.haomeiwen.com/subject/yxduoqtx.html