加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 使用crontab在@reboot上运行“screen -S name ./script

发布时间:2020-12-14 01:23:05 所属栏目:Linux 来源:网络整理
导读:我已经尝试将此添加到我的crontab: @reboot / root / startup “启动”文件: #!/bin/shsvnserve -d -r /root/svnrepos/mainressvnserve -d -r /root/svnrepos/mapres --listen-port=3691screen -S mta ./mtaserver/mta-server log1screen -S mapmta ./maps
我已经尝试将此添加到我的crontab:

@reboot / root / startup

“启动”文件:

#!/bin/sh

svnserve -d -r /root/svnrepos/mainres
svnserve -d -r /root/svnrepos/mapres --listen-port=3691
screen -S mta ./mtaserver/mta-server > log1
screen -S mapmta ./mapserver/mta-server > log2

exit 0

现在svnserve命令运行正常.问题在于screen命令.

log1和log2文件具有相同的内容:必须连接到终端.

我要做的是在启动时启动2个可执行文件,然后再有办法访问它们.

有没有办法做到这一点?

解决方法

您想要在’screen’命令中添加以下选项(例如在-S之前): – d -m
从联机帮助页:

-d -m   Start screen in "detached" mode. This creates a new session but
           doesn't  attach  to  it.  This  is  useful  for  system startup
           scripts.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读