使用crontab在@reboot上运行"screen -S name ./script"命令

Ahm*_*mdy 4 linux cron reboot gnu-screen

我已经尝试将此添加到我的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
Run Code Online (Sandbox Code Playgroud)

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

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

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

有没有办法做到这一点?

AMA*_*nc. 9

您想要在'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.
Run Code Online (Sandbox Code Playgroud)