I would like to execute a shell script with non-root user while Linux system booting and oracle has been started successfully.
I tried to execute this shell in rc.local. But I found oracle start-up procedure took too much time. So when shell tried to connect to Oracle, it return failed.
On the user`s Linux server, it took several minutes to get Oracle running. I am not clear what technology they use. I found when Oracle didn`t startup finished, I can login Linux server through ssh.
In my opinion, Linux boot sequence should like following.
/etc/rc.d/rc.sysinit
/etc/rc.d/rc $RUNLEVEL
/etc/rc.d/rc.local
/bin/login
But If I add line to check if Oracle is running in rc.local, user cannot login Linux server for several minutes. I think it is improper.
Is there a better solution to solve this problem?
Any suggestion is welcome.
Use one of this solutions and configure it to "wait" for oracle listen port.
https://github.com/vishnubob/wait-for-it
Or
https://github.com/Eficode/wait-for
Related
I'm using Django on Ubuntu 18.04.
I've got everything set up. And I type python manage.py run_huey in the server (through an SSH connection) to start huey, and it works.
However this is done through the command line through SSH and it will shut off when I close the SSH connection.
How do I keep run_huey running so that it will stay active at all times? Furthermore, after a system reboot, how do I get run_huey to automatically start?
You may explore supervisorctl utility for ubuntu, it keeps process running and can log into file and any other features. Google it.
I would like to make tomcat auto start with a non-root user while system booting. I have created a daemon.sh under folder /etc/init.d . And I executed chkconfig tomcat on. The linux server is in another city. I access it by ssh. And I cannot reboot server to test it.
The problem is if tomcat start failed while booting, I am afraid that linux server cannot not be start succesfully. That whould be a disaster for me. Perhaps my worry is unnecessary.
How to avoid this problem?
I have a powershell script on my Windows server which does some active directory operations. I wish to call that script from another Linux machine using a shell script.
I have installed powershell server on my Windows server and can communicate with my linux machine using key based ssh authentication.
Since Windows does not support SSH connections on its own, I have installed a software called Powershell server (http://www.powershellserver.com/) on my Windows server.
The issue is that my script just stops once the command for ssh to Windows server is executed.
My shell script below:
#!/bin/bash
echo "script run"
GROUP=$1
ACCOUNT=$2
ssh Administrator#<Windowshostname>
sleep 10
echo "<pathtoscript>\scriptname.ps1 -group $GROUP -account $ACCOUNT"
sleep 5
echo "exit"
exit
I have tried without the echo command as well and it still hangs. Any idea what I must be doing wrong here? How can I make it work please?
You cannot ssh into a Windows box unless you install a SSH daemon.
You have two options:
1- You need to connect via Remote PowerShell (WINRM).
2- Install SSH daemon and connect via SSH (Check here)
3- You can also use PowerShell Web Access (Windows Servers.)
UPDATE: If you are using PowerShellServer.com then there are some things you can do to try to understand more.
Test scriptname.ps1 locally in Windows Server
Edit your scriptname.ps1 in the first line to create a file somewhere and after execution check if that file exists. This way you will know if script is being executed or not.
Execute Get-ExecutionPolicy and check you can run scripts. Remove constraints by temporary Set-ExecutionPolicy unrestricted
Tried the operation using an "expect" script and it all works well now.
I am using Neo4j 2.0.3 Community server by installing it on my linux system (by unzipping the tar.gz). I got this error while I tried to start the server
WARNING! You are using an unsupported Java runtime.
process [50690]... waiting for server to be ready.neo4j-community-2.0.3/bin/neo4j: line 147: lsof : command not found
.neo4j-community-2.0.3/bin/neo4j: line 147: lsof : command not found
.neo4j-community-2.0.3/bin/neo4j: line 147: lsof : command not found
. Failed to start within 120 seconds.
Neo4j Server may have failed to start, please check the logs.
I checked for the solution for this and came to know that /usr/sbin had to be added to the path. On doing so and restarting the server, I got the following message
Another server-process is running with [40903], cannot start a new one. Exiting.
However, when I run the command neo4j staus , it says
Neo4j Server is not running
Can anybody please help me with how should I get started with it?
This is very late, but might help others.
If it tells you this, and you check that process id with, for example, ps aux | grep 40903, and it's not neo4j, the problem might be that the port is being used.
By default neo4j uses 7474, but can change this on the neo4j folder /conf/neo4j-server.properties and that was my problem, I had set the port to '22' which was being used. SO make sure it is set to a port that is open and available.
Hope this helps.
You might want to examine the startup script.
Another server-process is running with [40903], cannot start a new one. Exiting.
indicates (me to) that there might be a pid file (or the script uses them) which was written and is checked before attempting to start a new instances. This the normal thing to do.
I think you need to kill the other process using kill
You can see this answer for how to kill the process:
https://unix.stackexchange.com/questions/8916/when-should-i-not-kill-9-a-process
Otherwise, restarting the operating system will also do the job. For me, I normally start neo4j in the console, as in ./neo4j console. This makes it easier to stop the process.
I have ssh-ed to a remote machine. I have enabled X11 forwarding (ssh -X) and I have started a GUI program.
The program takes 5 minutes to set up to do some processing but the actual processing takes 1-2 hours. I don't want to stream data while the program is working. I don't even want to see the program again as it produces files as output when it finishes and I can just scp them.
So how can I quit the ssh session but leave the program running on the machine? CRTL+C in the terminal?
EDIT: For the answer please see my comment just below.
Long story short - you can't do this without making some modifications to the way you run things. A GUI application requires for an X server target to be accepting it's GUI updates - if you're using your local X server to do this, then it'll require (1) the connection to be open (2) that you actually handle the updates.
A way around this is to use something like Xvfb - which is a headless way of hosting a virtual X-server. Above and beyond the examples provided on the wikipedia page, folks who seem to make frequent use of this mechanism are Selenium users.
Awesome, I've been looking for an acceptable answer to my problem for hours, and finally one pops up. ssh -X -f login#machine yourprogram worked perfectly for me. Though I used ssh -Y -f login#machine yourprogram. This has been driving me nuts.
Like some people said, SSH -X is using your local X server, so it needs the connection. I had the same problem, wanted to quit ssh but leaving GUI applications running. To do this I installed X server and VNC server on the remote host. With a VNC client on your local computer, you can easily connect to the VNC server and disconnect leaving GUI applications running.
By the way, you will have better performances with VNC or X2Go. In my case, Firefox was very slow and some sites didn't load at all with SSH -X, even with -Y or -C optimizations.
Running ssh -X -f login#machine yourprogram should do the trick.
Starting your program with nohup program & will make it safe to just close your terminal - program will still be running.
You won't be able to see the UI after you end ssh session, but since you don't need it anyway - it's going to do the job.