Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


dt



521 posts

Ultimate Geek


# 242973 22-Nov-2018 09:06
Send private message

Hi,

 

So I have recently started playing with ubuntu server and have a few services running on it which im having some difficulty selecting and when I say difficulty I mean I have no idea how to select them again :-)

 

I execute a script which launches a listen server and after the listen server is up and running I've just been doing ctrl+z to break out of it

 

I've tried my best to google this, as I have with everything else I've learnt but since my knowledge is so limited on the subject I don't believe im googling the correct terms to get the correct results

 

Help appreciated as always

 

TIA

 

DT


Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2
1013 posts

Uber Geek

Trusted

  # 2131512 22-Nov-2018 09:13
Send private message

What version of ubuntu are you running? I haven't used it in a few years but iirc it sounds like you want to run this in a screen.

 

screen -d -m -t nameofscreen sh myscript.sh

 

You may want to look into having it run it as a service so it will launch at startup automatically


163 posts

Master Geek


  # 2131513 22-Nov-2018 09:13
Send private message

Handy link for you: ctrlz-and-ctrlc-in-unix-command-line

 

Short story:

 

use 'fg' to bring it back

 

 

 

 


 
 
 
 


701 posts

Ultimate Geek


  # 2131515 22-Nov-2018 09:17
Send private message

evnafets:

 

Handy link for you: ctrlz-and-ctrlc-in-unix-command-line

 

Short story:

 

use 'fg' to bring it back

 

 

Should add: fg to bring it back to the foreground.

 

Use bg to send it to run in the background.

 

To me the OP wasnt all that clear what is trying to be achieved. Are you trying to run the script as a service?


15223 posts

Uber Geek

Trusted
Subscriber

  # 2131548 22-Nov-2018 09:35
One person supports this post
Send private message

service start (servicename)

 

This typically runs a script that lives somewhere in the /etc folder.


628 posts

Ultimate Geek
Inactive user


  # 2131563 22-Nov-2018 09:51
Send private message

timmmay:

 

service start (servicename)

 

 

service <servicename> start. Other command produces "start: unrecognized service" :P


5778 posts

Uber Geek

Moderator
Trusted
Lifetime subscriber

  # 2131566 22-Nov-2018 09:54
Send private message

Why Ubuntu?  I use CentOS but everyone has a preference I guess.  Ubuntu hasn't been great in recent versions from what I hear.


dt



521 posts

Ultimate Geek


  # 2131567 22-Nov-2018 09:54
Send private message

Yeah sorry guys if im not making much sense, still an ultra n00b 

 

I'm running Ubuntu 16.04.5 LTS (latest supported version for the server im running on it)

 

After reading the link above it looks like ctrl+z isn't the correct command for me to use as I dont want to suspend the service, its the only command I could figure out to "break out" so I could get the command line back

 

I'll try and explain what im trying to achieve a little better

 

I run my listen server by executing a script via ./myserver.sh

 

this gets my server up and running but it takes over the whole terminal (ssh'd in via putty)

 

in the Microsoft world I would say its in my focus and I want to minimize it so I can get back to the OS, but then I also want to switch back to it when I want access to the listen servers console

 

hope that makes more sense? 

 

 


 
 
 
 


dt



521 posts

Ultimate Geek


  # 2131573 22-Nov-2018 10:04
Send private message

gehenna:

 

Why Ubuntu?  I use CentOS but everyone has a preference I guess.  Ubuntu hasn't been great in recent versions from what I hear.

 

 

 

 

Its the recommended/supported os of what im trying to do

 

I originally had 18.04 LTS running but kept running into problems with the listen server because of it.. big learning curve for a windows server guy :) 


701 posts

Ultimate Geek


  # 2131614 22-Nov-2018 10:13
Send private message

dt:

 

Yeah sorry guys if im not making much sense, still an ultra n00b 

 

I'm running Ubuntu 16.04.5 LTS (latest supported version for the server im running on it)

 

After reading the link above it looks like ctrl+z isn't the correct command for me to use as I dont want to suspend the service, its the only command I could figure out to "break out" so I could get the command line back

 

I'll try and explain what im trying to achieve a little better

 

I run my listen server by executing a script via ./myserver.sh

 

this gets my server up and running but it takes over the whole terminal (ssh'd in via putty)

 

in the Microsoft world I would say its in my focus and I want to minimize it so I can get back to the OS, but then I also want to switch back to it when I want access to the listen servers console

 

hope that makes more sense? 

 

 

 

 

 

 

So the quick and simple solution might simply be:

 

 ./myserver.sh &

 

The & will tell your shell to run it in the background and return the prompt to you.  The issue is that you'll have to do this manually everytime you want to start your service.  If you want it to happen automatically whenever you restart your host you'll need to create a systemd service.  For that part start here: https://askubuntu.com/questions/919054/how-do-i-run-a-single-command-at-startup-using-systemd  But before you get there...lets make sure the above is what you want


dt



521 posts

Ultimate Geek


  # 2131628 22-Nov-2018 10:29
Send private message

nzkc:

 

So the quick and simple solution might simply be:

 

 ./myserver.sh &

 

The & will tell your shell to run it in the background and return the prompt to you.  The issue is that you'll have to do this manually everytime you want to start your service.  If you want it to happen automatically whenever you restart your host you'll need to create a systemd service.  For that part start here: https://askubuntu.com/questions/919054/how-do-i-run-a-single-command-at-startup-using-systemd  But before you get there...lets make sure the above is what you want

 

 

 

 

it sounds like it, will give it a go in a few moments.

 

if it does do what I want, should I be able to use fg to bring it back into view ? 


701 posts

Ultimate Geek


  # 2131785 22-Nov-2018 12:39
Send private message

Yes. And you can use the jobs command to see what background tasks you have.  Do note that if you logout of that session that job will stop.  You need to use nohup or screen to avoid that.


98 posts

Master Geek


  # 2131820 22-Nov-2018 13:23
One person supports this post
Send private message

nohup ./myserver.sh > /var/log/myserver.log 2>&1 &

 

nohup - so you can logout without terminating script
> - /var/log/myserver.log - send STDOUT to log file (use >> if you want to append to existing log)
2>&1 - send STDERR to the same place a STDOUT
& - background the job

 

 


375 posts

Ultimate Geek


# 2131831 22-Nov-2018 13:35
Send private message

Or open up a second SSH window. You can run loads at the same time (unlike Windows :-p)


610 posts

Ultimate Geek


  # 2131838 22-Nov-2018 13:37
One person supports this post
Send private message

For something like a server that runs often and for long periods of time, I highly recommend creating a systemd service rather than using any of the other methods. Once set up, it's easy to make the server run automatically on startup, restart if stopped, or start/stop it at will.

 

If you'll run this server only once in a while, and aren't bothered about being able to do any of the things above, then just use screen.


15223 posts

Uber Geek

Trusted
Subscriber

  # 2131844 22-Nov-2018 13:44
Send private message

stinger:

 

timmmay:

 

service start (servicename)

 

 

service <servicename> start. Other command produces "start: unrecognized service" :P

 

 

You need to set it up as a service. It's not that difficult. With that it's easy to start on system start, the OS will ensure it stays up, that kind of thing.


 1 | 2
Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic



Twitter and LinkedIn »



Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

Logitech introduces new Made for Google keyboard and mouse devices
Posted 16-Oct-2019 13:36


MATTR launches to accelerate decentralised identity
Posted 16-Oct-2019 10:28


Vodafone X-Squad powers up for customers
Posted 16-Oct-2019 08:15


D Link ANZ launches EXO Smart Mesh Wi Fi Routers with McAfee protection
Posted 15-Oct-2019 11:31


Major Japanese retailer partners with smart New Zealand technology IMAGR
Posted 14-Oct-2019 10:29


Ola pioneers one-time passcode feature to fight rideshare fraud
Posted 14-Oct-2019 10:24


Spark Sport new home of NZC matches from 2020
Posted 10-Oct-2019 09:59


Meet Nola, Noel Leeming's new digital employee
Posted 4-Oct-2019 08:07


Registrations for Sprout Accelerator open for 2020 season
Posted 4-Oct-2019 08:02


Teletrac Navman welcomes AI tech leader Jens Meggers as new President
Posted 4-Oct-2019 07:41


Vodafone makes voice of 4G (VoLTE) official
Posted 4-Oct-2019 07:36


2degrees Reaches Milestone of 100,000 Broadband Customers
Posted 1-Oct-2019 09:17


Nokia 1 Plus available in New Zealand from 2nd October
Posted 30-Sep-2019 17:46


Ola integrates Apple Pay as payment method in New Zealand
Posted 25-Sep-2019 09:51


Facebook Portal to land in New Zealand
Posted 19-Sep-2019 18:35



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.