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



367 posts

Ultimate Geek
+1 received by user: 54


Topic # 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
979 posts

Ultimate Geek
+1 received by user: 640

Trusted

  Reply # 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


134 posts

Master Geek
+1 received by user: 43


  Reply # 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

 

 

 

 


 
 
 
 


523 posts

Ultimate Geek
+1 received by user: 114


  Reply # 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?


14500 posts

Uber Geek
+1 received by user: 2669

Trusted
Subscriber

  Reply # 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.





AWS Certified Solution Architect Professional, Sysop Administrator Associate, and Developer Associate
TOGAF certified enterprise architect
Professional photographer


629 posts

Ultimate Geek
+1 received by user: 176
Inactive user


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

timmmay:

 

service start (servicename)

 

 

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


5367 posts

Uber Geek
+1 received by user: 1412

Moderator
Trusted
Lifetime subscriber

  Reply # 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



367 posts

Ultimate Geek
+1 received by user: 54


  Reply # 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



367 posts

Ultimate Geek
+1 received by user: 54


  Reply # 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 :) 


523 posts

Ultimate Geek
+1 received by user: 114


  Reply # 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



367 posts

Ultimate Geek
+1 received by user: 54


  Reply # 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 ? 


523 posts

Ultimate Geek
+1 received by user: 114


  Reply # 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
+1 received by user: 56


  Reply # 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

 

 


355 posts

Ultimate Geek
+1 received by user: 60


Reply # 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)


521 posts

Ultimate Geek
+1 received by user: 282


  Reply # 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.


14500 posts

Uber Geek
+1 received by user: 2669

Trusted
Subscriber

  Reply # 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.





AWS Certified Solution Architect Professional, Sysop Administrator Associate, and Developer Associate
TOGAF certified enterprise architect
Professional photographer


 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


Donate via Givealittle


Twitter »

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 »

Amazon introduces new Kindle with adjustable front light
Posted 21-Mar-2019 20:14


A call from the companies providing internet access for the great majority of New Zealanders, to the companies with the greatest influence over social media content
Posted 19-Mar-2019 15:21


Two e-scooter companies selected for Wellington trial
Posted 15-Mar-2019 17:33


GeForce GTX 1660 available now
Posted 15-Mar-2019 08:47


Artificial Intelligence to double the rate of innovation in New Zealand by 2021
Posted 13-Mar-2019 14:47


LG demonstrates smart home concepts at LG InnoFest
Posted 13-Mar-2019 14:45


New Zealanders buying more expensive smartphones
Posted 11-Mar-2019 09:52


2degrees Offers Amazon Prime Video to Broadband Customers
Posted 8-Mar-2019 14:10


D-Link ANZ launches D-Fend AC2600 Wi-Fi Router Protected by McAfee
Posted 7-Mar-2019 11:09


Slingshot commissions celebrities to design new modems
Posted 5-Mar-2019 08:58


Symantec Annual Threat Report reveals more ambitious, destructive and stealthy attacks
Posted 28-Feb-2019 10:14


FUJIFILM launches high performing X-T30
Posted 28-Feb-2019 09:40


Netflix is killing content piracy says research
Posted 28-Feb-2019 09:33


Trend Micro finds shifting threats require kiwis to rethink security priorities
Posted 28-Feb-2019 09:27


Mainfreight uses Spark IoT Asset Tracking service
Posted 28-Feb-2019 09:25



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.