Need help with simple startup bash script in CentOS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with simple startup bash script in CentOS
# 1  
Old 09-28-2013
Need help with simple startup bash script in CentOS

Hi guys,

I am very new to linux, so please bear with me. Image

I need a simple script (bash / .sh) to start 2 programs at server startup. Both programs should run in a detached screen of their own.

So basically:
1) start a detached screen with Program A running in it
2) start a new detached screen with Program B running in it

I have it already set up that it runs a 'start.sh' script on startup - so that part works. I just need the script itself.

I've tested a bunch of things that I've found on the internet, but nothing really works.

My latest test is this:
Code:
#!/bin/bash
screen -dmS "minecraft" sh -c 'cd  /root/lastcrafters; ./MCMA2_Linux_x86_64' &
screen -dmS "teamspeak" sh -c  '/root/lastcrafters/teamspeak/ts3server_startscript.sh start; exec bash' &

Each of the 2 commands work flawless when copy/pasted into Putty. But for some reason in the startup script they dont always work properly. Sometimes it works fine and both programs start as wanted. Sometimes only 1 of the 2 programs will start, and sometimes one of the programs will start doubled (once with a screen and once without a screen).

I have absolutely NO idea why this is. I have tried a sleep command between the 2 lines, to give it some time or something, but that didnt work either.

The 'exec bash' in the 2nd command is to keep the screen from closing, because teamspeak doesnt do anything in the screen and thus the screen would close from inactivity.

The 1st command doesnt need this, as Minecraft keeps spitting out things in the screen anyways.

I appreciate ANY and all help. Image Thank you for your time.

P.S.: I'm also open to any other/better way to get my goal accomplished. However, as I am completely new to linux, please explain thoroughly what I would have to do etc. Image
# 2  
Old 09-28-2013
Times out?

Code:
echo $TMOUT

Please show the output of that command.

For starters, is there a reason you cannot login 3 times or must both of these commands run from the same parent process?
Code:
  login - cmd1  (no trailing &)
  login - cmd2  (no trailing &)
  login - play minecraft

As opposed to
Code:
                 login
                    |
      -----------------------------------------------------------
      ||                         ||                                   ||
    cmd1 &                    cmd2 &                                minecraft


You can login to separate, new, and unrelated processes as many times as needed in Linux. Normally there is point to doing that.

Where did you get the instructions to do this ? From the website or some other source.
# 3  
Old 09-28-2013
If the server has a GUI (X with any DE - Desktop Environment or WM - Window Manager), it could be quite easy...

First locate, their desktopfiles ('Similar' to desktoplinks in Windows (it droped (plain-)text-links back around 1995):

Lets say your filemanager is "nautilus", start it as root to look for the links:
Code:
su -c "nautilus /usr/share/applications/"

Once you found minecraft and ts-server, place (copy-paste) those 2 files in "/etc/xdg/autostart", as the browser was started as root, there should be no problem doing so...

And in theory, you should be able to restart and they should get started on boot (to gui).

hth
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Apache tomcat startup script not booting at startup.

I copied the script from an AskUbuntu post - #!/bin/bash ### BEGIN INIT INFO # Provides: tomcat7 # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop Tomcat server ### END INIT INFO ... (14 Replies)
Discussion started by: Hijanoqu
14 Replies

2. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

3. Shell Programming and Scripting

Simple bash script help

Hi to everyone here, I'm a new user and relatively-new linuxer. I'm trying to write a script that checks if every file from a directory is present in a given list and if not, delete it. should be simple. But I think I've done half the work only: this is to create the reference list: for c... (2 Replies)
Discussion started by: dentex
2 Replies

4. Shell Programming and Scripting

need a simple bash script

to gather the cpu utilization from a system in 5 minute intervals and direct output to file. I'm new at scripting and while this seems like an easy task I'm confused on where to start. thanks for any help (1 Reply)
Discussion started by: mkeyes001
1 Replies

5. Shell Programming and Scripting

simple bash script permission

I have a bash script, but it needs to have a simple protection with password. So if a user wants to run the script , there should be a kdialog to asks for a password.If the password is correct the script starts to run. It should not be the passord of root or another admin user.Just a password in... (2 Replies)
Discussion started by: poort
2 Replies

6. Shell Programming and Scripting

Bash script on startup does not respond as expected

Hi, I have a bash script which I have referenced in the rc.local of my fedora linux OS. However it doesnt respond the same as when run in terminal from fedora. The bash script has a series of interactive questions that require user input as shown: #!/bin/bash echo "Do you want to use... (1 Reply)
Discussion started by: Crigamorfin
1 Replies

7. Shell Programming and Scripting

simple bash script

I am writing a shell script in bash one of the thing I want to show is size of export /home du -sk /export/home/oracle | cut -c 1-5 echo "kbytes" when I run the script kbytes shows up in the second line, How can I append kbytes on the same line, such as 61233 kbytes please guide thanks (2 Replies)
Discussion started by: Tirmazi
2 Replies

8. Shell Programming and Scripting

unzip via bash startup script problems

i have two lines in my rc.local file that are wget -O/<path>/<file>.zip url://domain.com unzip -o /<path>/<file>.zip the wget works fine, but the unzip won't work. when i copy/pase the unzip line to the prompt it works fine. i thought that maybe the unzip was running before the wget... (0 Replies)
Discussion started by: easysnowboards
0 Replies

9. Shell Programming and Scripting

Simple BASH script?

Hi guys, I'm new to the forum so forgive me if I'm sounding ... daft. I currently work in a Tech Support role. Every day we have to generate data by running around 10 .sh scripts. I was thinking instead of having to ./filename 10 times is it possible to right a new script that will run these for... (16 Replies)
Discussion started by: JayC89
16 Replies

10. Shell Programming and Scripting

Simple Bash Script

I'm sure I'm doing something wrong but as I am new to bash shell scripting I'm not sure what: Here's the code webalizer.conf is sitting in the same directory as this file which is named webalizer.sh. Can someone tell me if I've got the syntax right -- it that's correct? I'm executing the... (3 Replies)
Discussion started by: xaphalanx
3 Replies
Login or Register to Ask a Question