搜索
您的当前位置:首页正文

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

来源:二三娱乐
编译
> 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
nohup ./custom_name&

Top