golang在linux下面设置开机启动

netaxcess · 2015-04-16 07:11:07 · 4016 次点击 · 大约8小时之前 开始浏览    置顶
这是一个创建于 2015-04-16 07:11:07 的主题,其中的信息可能已经有所发展或是发生改变。

写了个goods_wg.go在/data0/go/src/xiyu/目录,我的go安装在/usr/local/go/目录。我想让goods_wg.go在linux下面实现开机就自动运行这个go文件。我把以下命令

/usr/local/go/bin/go run /data0/go/src/xiyu/goods_wg.go &放到/etc/rc.local里面去,但是开机的时候。依然无法运行这段go,但是我在linux开机之后,直接在linux下面运行

/usr/local/go/bin/go run /data0/go/src/xiyu/goods_wg.go &

这段命令,就能正常运行goods_wg.go了。请问要如何处理呢


有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

4016 次点击  
加入收藏 微博
2 回复  |  直到 2015-04-16 16:25:40
cnchanghai
cnchanghai · #1 · 10年之前

$ cat /etc/rc.local

#!/bin/sh -e #

rc.local

#

This script is executed at the end of each multiuser runlevel.

Make sure that the script will "exit 0" on success or any other

value on error.

#

In order to enable or disable this script just change the execution

bits.

#

By default this script does nothing.

exit 0

netaxcess
netaxcess · #2 · 10年之前
cnchanghaicnchanghai #1 回复

$ cat /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0

谢谢你的指点,首先这段go程序肯定没问题。可以单独跑,其次我直接在linux命令行下面输入/usr/local/go/bin/go run /data0/go/src/xiyu/goods_wg.go & 也可以让go执行,但是我把他放到/etc/rc.local里的时候。就无法执行了。

添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传