Why 'ps' command works different in oracle Linux and CentOS [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am trying to check whether the pmon process is running or not in CentOS and Oracle Linux over shell command. I used below command.
In CentOS :
ps -e | grep pmon;echo $?
Output
61577 ? 00:00:00 ora_pmon_orcl
0
But, in Oracle Linux:
ps -e | grep pmon;echo $?
Output
1
I am not able to understand why they behave differently.
Can I get a command which will work on both OS as below
1 output for process not running
0 output for process running

Edit: As suggested by Vatine and Dipak
Try running this
ps -ef|grep [p]mon|wc -l|awk '{if ($1 != 0) print "0"; else print "1";}'
It will return 1 if process is not running and 0 if it is running.

Related

How do I run `forever` from Crontab? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I am trying to schedule node server restart on OS reboot (Ubuntu 16.04 LTS). I wrote:
crontab -u username -e
then I added following line:
#reboot /usr/local/bin/forever start -c /usr/bin/node /home/username/node/bin/www
I get the success message after saving or updating this file. There seems to be no effect on server reboot.
I'd wrap that into a bash script in the user's home directory's bin.
/home/username/bin/start_my_node_app.sh
Then in your crontab...
#reboot /home/username/bin/start_my_node_app.sh >/dev/null 2>&1
Though according to this article, #reboot may not work for non-root users.
https://unix.stackexchange.com/questions/109804/crontabs-reboot-only-works-for-root

Issue with changing login shell [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I want to change the default login shell on my Ubuntu.
To change the shell I ran the following:
$ chsh -s /usr/bin/zsh
After that I restart my terminal but my default shell is still bash.
$ echo $SHELL
/bin/bash
These are shells installed on my machine:
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/bin/zsh
/usr/bin/zsh
Record for my user in /etc/passwd is also changed like expected:
$ cat /etc/passwd|grep myuser
myuser:x:1000:1000:myuser,,,:/home/myuser:/usr/bin/zsh
I successfully changed my login shell the same way on my mac but I seem to be having some issue on Ubuntu. Am I missing something here?
You need to logout and log back into Ubuntu so that your GUI based X terminal shells pick up the new shell value.
Note: Ctrl+Alt+F[1-6] represent 6 virtual shells while GUI login is on Ctrl+Alt+F7

Why can not stop vsftpd server? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am use Ubuntu Linux, and when I run command netstat -lt, then show:
tcp 0 0 *:ftp *:* LISTEN
then I run command sudo service vsftpd stop, and run command netstat -lt again, the terminal will not show ftp server, but after a while, I am run command netstat -lt again, the terminal will show ftp server again:
tcp 0 0 *:ftp *:* LISTEN
How strange it is!
How can I stop ftp server?
You may have another ftpd service.
Try with this:
# ps -ef | grep ftpd
And search for ftpd daemons.

How do I schedule a timed reboot of my server in seconds? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I’m using bash shell on Linux …
$ uname -a
Linux sandbox.mydomain.com 3.4.76-65.111.amzn1.x86_64 #1 SMP Tue Jan 14 21:06:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
although it would be nice if I could come up with a solution in any bash supported environment. My question is, in my script I want to scheduled a delayed reboot of my server in 5 seconds. So far, I have the below, but it takes 60 seconds …
# Timed reboot of server
sudo shutdown -r 1
# Fail if any of the sub-deployments failed.
if [[ ( $PROC1_STATUS -ne 0 ) ||
( $PROC2_STATUS -ne 0 ) ||
( $PROC3_STATUS -ne 0 ) ]]
then
exit 1;
fi
Does anyone know how I can adjust the above except make the timed reboot in 5 seconds instead of a minute? The solution doesn't have to use "shutdown" but it was the only tool I could find.
Dave
Try
sleep 5 ; reboot
on your terminal (as root). If you want it in the background, try
( sleep 5 ; reboot ) &
See also shutdown(8)

kill remote process by ssh [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I can't directly access target host, need ssh as a proxy.
How can I kill a process from local use ssh ? I try this:
ssh root#$center "ssh root#$ip \"ps -ef|grep -v grep|grep $target_dir/$main|awk '{print \$2}'|xargs kill\""
it got error:
kill: can't find process "root"
And how to avoid error where process not exist ?
Suppose your process' name is name, then you can try something like this:
ssh hostname "pid=\$(ps aux | grep 'name' | awk '{print \$2}' | head -1); echo \$pid |xargs kill"
Use pkill -f to easily kill a process by matching its command-line.
ssh root#$center ssh root#$ip pkill -f "$target_dir/$main"

Resources