Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run "screen -S name ./script" command on @reboot using crontab

I've tried adding this to my crontab:

@reboot /root/startup

The "startup" file:

#!/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

Now svnserve commands run fine. The problem is with the screen command.

log1 and log2 files have the same content which is: Must be connected to a terminal.

What I'm trying to do is start the 2 executables on startup, and then later have a way to access them.

Is there a way to do this?

like image 448
Ahmed Hamdy Avatar asked Jan 14 '23 00:01

Ahmed Hamdy


1 Answers

You want to add the following options to the 'screen' commands (e.g. before -S): -d -m From the manpage:

   -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.
like image 113
AMADANON Inc. Avatar answered Jan 16 '23 01:01

AMADANON Inc.