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

dt

1152 posts

Uber Geek
Inactive user


#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
Andib
1363 posts

Uber Geek

ID Verified
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





<# 
       .DISCLAIMER
       Anything I post is my own and not the views of my past/present/future employer.
#>




evnafets
537 posts

Ultimate Geek

Lifetime subscriber

  #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

 

 

 

 


nzkc
1571 posts

Uber 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?




timmmay
20574 posts

Uber Geek

Trusted
Lifetime subscriber

  #2131548 22-Nov-2018 09:35
Send private message

service start (servicename)

 

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


stinger
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


gehenna
8495 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

dt

1152 posts

Uber Geek
Inactive user


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

 

 


 
 
 

Cloud spending continues to surge globally, but most organisations haven’t made the changes necessary to maximise the value and cost-efficiency benefits of their cloud investments. Download the whitepaper From Overspend to Advantage now.

dt

dt

1152 posts

Uber Geek
Inactive user


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


nzkc
1571 posts

Uber 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

dt

1152 posts

Uber Geek
Inactive user


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


nzkc
1571 posts

Uber 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.


Peamsable
98 posts

Master Geek
Inactive user


  #2131820 22-Nov-2018 13:23

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

 

 


huckster
842 posts

Ultimate Geek

ID Verified
Lifetime subscriber

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


allio
885 posts

Ultimate Geek


  #2131838 22-Nov-2018 13:37
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.


timmmay
20574 posts

Uber Geek

Trusted
Lifetime 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





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

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



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.