# screen at bootup?



## mtwiscool (Jun 19, 2014)

I want to be able to run screen with a .sh script at boot up.

I have tried corn jobs but it won't launch.

Is they any way to do this?


----------



## MartinD (Jun 19, 2014)

Do a search for rc scripts, that's what you need.


----------



## raj (Jun 19, 2014)

http://askubuntu.com/questions/261899/run-a-screen-session-on-boot-from-rc-local


----------



## tonyg (Jun 19, 2014)

The way that I launch unattended screen sessions from a script is:

screen -d -m process_name


----------



## lvps (Jun 19, 2014)

Try to put the command in your /etc/rc.local file.


----------



## fisle (Jun 19, 2014)




----------



## Mun (Jun 19, 2014)

nano /etc/rc.local

Before the exit put your command with 'screen -d -m' before it. If you don't wish to run as root then su - <user> -c "screen -d -m command" &

Then exit and restart server to check.


----------



## mtwiscool (Jun 19, 2014)

Mun said:


> nano /etc/rc.local
> 
> Before the exit put your command with 'screen -d -m' before it. If you don't wish to run as root then su - <user> -c "screen -d -m command" &
> 
> Then exit and restart server to check.


Not working 


```
#!/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.
screen -d -m ./1.sh
exit 0
```


----------



## AshleyUK (Jun 19, 2014)

Your need to put the full location of the script and not ./

,Ashley


----------



## mtwiscool (Jun 19, 2014)

AshleyUK said:


> Your need to put the full location of the script and not ./
> 
> ,Ashley




```
#!/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.
screen -d -m /root/1.sh
exit 0
```


----------



## AshleyUK (Jun 19, 2014)

Correct, have you tried that?

,Ashley


----------



## mtwiscool (Jun 19, 2014)

Yes i have tried that and it does not work.


----------



## tonyg (Jun 19, 2014)

Just create a new /etc/init.d/ script and launch it from there.

Forget about /etc//rc.local


----------



## mtwiscool (Jun 19, 2014)

tonyg said:


> Just create a new /etc/init.d/ script and launch it from there.
> 
> Forget about /etc//rc.local


my sh script.


```
#!/bin/bash
tcptunnel --local-port=22 --remote-port=4722 --remote-host=95.128.47.39 --bind-address=23.94.62.8 --stay-alive & tcptunnel --local-port=80 --remote-port=4723 --remote-host=95.128.47.39 --bind-address=23.94.62.8 --stay-alive & tcptunnel --local-port=22 --remote-port=5522 --remote-host=95.128.47.39 --bind-address=23.94.62.7 --stay-alive & tcptunnel --local-port=80 --remote-port=5524 --remote-host=95.128.47.39 --bind-address=23.94.62.7 --stay-alive
```


----------



## tonyg (Jun 19, 2014)

mtwiscool said:


> my sh script.
> 
> 
> #!/bin/bash
> tcptunnel --local-port=22 --remote-port=4722 --remote-host=95.128.47.39 --bind-address=23.94.62.8 --stay-alive & tcptunnel --local-port=80 --remote-port=4723 --remote-host=95.128.47.39 --bind-address=23.94.62.8 --stay-alive & tcptunnel --local-port=22 --remote-port=5522 --remote-host=95.128.47.39 --bind-address=23.94.62.7 --stay-alive & tcptunnel --local-port=80 --remote-port=5524 --remote-host=95.128.47.39 --bind-address=23.94.62.7 --stay-alive


Where is the screen command?

Which OS?


----------



## raj (Jun 19, 2014)

@OP can you elaborate on what "doesn't work" means?  Are you seeing errors in your logs?  Did it do nothing? Is it giving you a path issue?


----------



## mtwiscool (Jun 19, 2014)

raj said:


> @OP can you elaborate on what "doesn't work" means?  Are you seeing errors in your logs?  Did it do nothing? Is it giving you a path issue?


what error log is it in?


----------



## raj (Jun 19, 2014)

Depends on what you're running.  Check /var/log/messages or /var/log/syslog or /var/log/daemon or something of that sort.


----------



## mtwiscool (Jun 19, 2014)

raj said:


> Depends on what you're running.  Check /var/log/messages or /var/log/syslog or /var/log/daemon or something of that sort.


Strange nothing in the logs for this #strange


----------



## Deleted (Jun 19, 2014)

IIRC, rc.local won't work because of the tty/devfs system isn't init'd/mounted until after.


----------



## 5n1p (Jun 19, 2014)

Try to add it like this in rc.local


```
cd /root && screen -d -m ./1.sh
```


----------



## mtwiscool (Jun 20, 2014)

5n1p said:


> Try to add it like this in rc.local
> 
> 
> cd /root && screen -d -m ./1.sh


That is really strange it still does not work.

program trying to launch in a screen is tcptunnel.


----------

